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

Loader.java Memory Leak (StrictMode Failure to Load Class) #53

Closed
Jamoke opened this issue Dec 9, 2015 · 2 comments
Closed

Loader.java Memory Leak (StrictMode Failure to Load Class) #53

Jamoke opened this issue Dec 9, 2015 · 2 comments
Labels

Comments

@Jamoke
Copy link

Jamoke commented Dec 9, 2015

So - I'm using Android Studio 1.5 and Gradle 2.8 and Proguard 5.2.1. My project is running ProGuard settings and stripping things out per the instructions here:

https://github.com/bytedeco/javacv/wiki/Configuring-Proguard-for-JavaCV

However, what I'm finding is that there is an issue where line 131 of Loader.java opens an InputStream, which isn't ever closed. Here is the stacktrace.

E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
E/StrictMode: java.lang.Throwable: Explicit termination method 'end' not called
E/StrictMode:     at dalvik.system.CloseGuard.open(CloseGuard.java:184)
E/StrictMode:     at java.util.zip.Inflater.<init>(Inflater.java:82)
E/StrictMode:     at java.util.zip.ZipFile.getInputStream(ZipFile.java:331)
E/StrictMode:     at java.util.jar.JarFile.getInputStream(JarFile.java:390)
E/StrictMode:     at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
E/StrictMode:     at java.net.URL.openStream(URL.java:470)
E/StrictMode:     at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
E/StrictMode:     at java.lang.Class.getResourceAsStream(Class.java:1412)
E/StrictMode:     at org.bytedeco.javacpp.Loader.loadProperties(Loader.java:131)
E/StrictMode:     at org.bytedeco.javacpp.Loader.loadProperties(Loader.java:114)
E/StrictMode:     at org.bytedeco.javacpp.Loader.load(Loader.java:399)
E/StrictMode:     at org.bytedeco.javacv.b.a(FFmpegFrameRecorder.java:91)
E/StrictMode:     at org.bytedeco.javacv.b.<clinit>(FFmpegFrameRecorder.java:112)
E/StrictMode:     at [myTestAppBundleIDRedacted].onCreate(TestActivity.java:90)
E/StrictMode:     at android.app.Activity.performCreate(Activity.java:6374)
E/StrictMode:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
E/StrictMode:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2767)
E/StrictMode:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2879)
E/StrictMode:     at android.app.ActivityThread.access$900(ActivityThread.java:182)
E/StrictMode:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
E/StrictMode:     at android.os.Handler.dispatchMessage(Handler.java:102)
E/StrictMode:     at android.os.Looper.loop(Looper.java:145)
E/StrictMode:     at android.app.ActivityThread.main(ActivityThread.java:6141)
E/StrictMode:     at java.lang.reflect.Method.invoke(Native Method)
E/StrictMode:     at java.lang.reflect.Method.invoke(Method.java:372)
E/StrictMode:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
E/StrictMode:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Specifically: org.bytedeco.javacpp.Loader.loadProperties(Loader.java:131) : InputStream is = Loader.class.getResourceAsStream(name);

I think the try statement just below this needs a finally clause added to close the stream so that StrictMode doesn't complain that it is never closed. Couldn't this cause a memory leak?

saudet added a commit that referenced this issue Dec 12, 2015
…` in `Loader` (issue #53)

 * Remove `Piper` class no longer needed with Java SE 7
@saudet saudet added the bug label Dec 12, 2015
@saudet
Copy link
Member

saudet commented Dec 12, 2015

Oh, look at that, I forgot to call close()! Thanks for reporting. Fixed in the latest commit.

@saudet
Copy link
Member

saudet commented May 19, 2016

Fix included in version 1.2. Thanks for reporting!

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

No branches or pull requests

2 participants