在附加的堆栈跟踪中获取了资源,但从未释放过。请参阅java.io.Closeable以获取有关避免资源泄漏以及为什么会发生这种情况的信息

时间:2019-02-11 17:59:34

标签: java android

02-11 23:03:34.679 5179-5187 / com.teyaar E / StrictMode:在附加的堆栈跟踪中获取了资源,但从未释放过。有关避免资源泄漏的信息,请参见java.io.Closeable。     java.lang.Throwable:未调用显式终止方法“ close”         在dalvik.system.CloseGuard.open(CloseGuard.java:180)         在com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:317)         在com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:212)         在com.android.okhttp.Connection.connect(Connection.java:1322)         在com.android.okhttp.Connection.connectAndSetOwner(Connection.java:1410)         在com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:131)         在com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:484)         在com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:465)         在com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:371)         在com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:468)         在com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:410)         在com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:532)         在com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)         在com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)         在android.media.MediaHTTPConnection.seekTo(MediaHTTPConnection.java:463)         在android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:722)         在android.media.MediaHTTPConnection.native_readAt(本地方法)         在android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:710)         在android.media.IMediaHTTPConnection $ Stub.onTransact(IMediaHTTPConnection.java:72)         在android.os.Binder.execTransact(Binder.java:453)

2 个答案:

答案 0 :(得分:0)

从错误看来,您好像使用了某个对象,该对象最终将被“关闭”,而您从未这样做。如果添加一些源代码,则更容易建议它到底是什么。

答案 1 :(得分:0)

Closable具有方法close,在不再需要该方法时,必须调用该方法以释放与该组件关联的资源。

要查找泄漏,可以尝试MAT,我经常用它来查找内存泄漏(静态数据包含对Activity的引用,等等)。