Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in HeapAnalyzer #141

Closed
HexBlit opened this issue May 21, 2015 · 8 comments
Closed

Memory leak in HeapAnalyzer #141

HexBlit opened this issue May 21, 2015 · 8 comments

Comments

@HexBlit
Copy link

HexBlit commented May 21, 2015

I am seeing a strictmode error with leakCanary that gives a possible memory leak.

A resource was acquired at attached stack trace but never released.
java.lang.Throwable: Explicit termination method 'end' not called
at com.squareup.leakcanary.HeapAnalyzer.openSnapshot(HeapAnalyzer.java:134)

@pyricau
Copy link
Member

pyricau commented May 22, 2015

Can you provide the full stacktrace please?

Also, which version of LeakCanary are you using?

@ninja-
Copy link

ninja- commented Jun 3, 2015

@pyricau the snapshot is not disposed

@HexBlit
Copy link
Author

HexBlit commented Jun 4, 2015

06-04 10:23:49.508: E/StrictMode(2323): at com.squareup.leakcanary.HeapAnalyzer.openSnapshot(HeapAnalyzer.java:134)
com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:87)
com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:56)

Here is the strict mode error that I am getting.

@HexBlit
Copy link
Author

HexBlit commented Jun 4, 2015

Here is a better stack trace result

 A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
 java.lang.Throwable: Explicit termination method 'end' not called
    at dalvik.system.CloseGuard.open(CloseGuard.java:184)
    at java.util.zip.Inflater.<init>(Inflater.java:82)
    at java.util.zip.ZipFile.getInputStream(ZipFile.java:331)
    at java.util.jar.JarFile.getInputStream(JarFile.java:390)
    at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
    at java.net.URL.openStream(URL.java:470)
    at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
    at org.eclipse.mat.util.MessageUtil.<init>(MessageUtil.java:27)
    at org.eclipse.mat.util.MessageUtil.<clinit>(MessageUtil.java:13)
    at org.eclipse.mat.util.MessageUtil.format(MessageUtil.java:18)
    at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:54)
    at org.eclipse.mat.parser.internal.SnapshotFactory.parse(SnapshotFactory.java:193)
    at org.eclipse.mat.parser.internal.SnapshotFactory.openSnapshot(SnapshotFactory.java:106)
    at com.squareup.leakcanary.HeapAnalyzer.openSnapshot(HeapAnalyzer.java:134)
    at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:87)
    at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:56)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.HandlerThread.run(HandlerThread.java:61)

@pop1030123
Copy link

there any solutions?

@ninja-
Copy link

ninja- commented Jun 25, 2015

yeah add snapshot.dispose() @pop1030123

@pyricau
Copy link
Member

pyricau commented Jul 14, 2015

@ninja- com.squareup.leakcanary.HeapAnalyzer#cleanup does call dispose, and is called in a finally block. Do you have more details about what the fix should be?

@pyricau
Copy link
Member

pyricau commented Jul 19, 2015

We're switching the backend in #219

@pyricau pyricau closed this as completed Jul 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants