Skip to content

关于远程调用导致应用出现memory leak问题 #89

@YiXueXin

Description

@YiXueXin
# https://github.com/pili-engineering/pili-sdk-java/blob/master/src/main/java/com/qiniu/pili/RPC.java 
 if (response.isSuccessful()) {
            ResponseBody responseBody = response.body();
            String responseString = responseBody.string();
            if (responseBody != null)
                responseBody.close();
            return responseString;
        } else {
            throw new PiliException(response);
        }

上述代码在远程未正常返回200时,执行throw new PiliException(response); 这句代码时无法释放引用,出现以下报错,在抛异常前调用response.close()即不会出现该问题.

2020-09-02 19:33:26.054  WARN 14216 --- [ ConnectionPool] okhttp3.OkHttpClient                     : A connection to http://pili.qiniuapi.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
2020-09-02 19:33:26.054  WARN 14216 --- [ ConnectionPool] okhttp3.OkHttpClient                     : A connection to http://pili.qiniuapi.com/ was leaked. Did you forget to close a response body? To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions