becauseWhyNot
Lurker
I've spend a day and an half now trying to chase the origin of a LeakedCloseableViolation in my app, developed to target API v32.
I have enabled strict mode with:
And in LogCat I get
Stacktrace doesn't appear to have any cause listed. I tried added getCause() to Violation that is thrown, but it returns Null.
I audited my code, and don't see any streams or observers, that are not being properly closed.
The error is perfectly reproducible.
I just open the app, and leave it open on the main Activity for 30 seconds. I don't touch the phone at all.
After 30 seconds, when garbage collection comes around, this error appear.
Anyone have any idea on how I can get more information about what is causing this issue?
I have enabled strict mode with:
Code:
StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyListener( this.getMainExecutor(), ( Violation v ) -> {
v.fillInStackTrace();
v.printStackTrace();
} )
.build());
Code:
W/System.err: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. Callsite: close
W/System.err: at com.wattthis.reflowmate.App.lambda$onCreate$0(App.java:30)
W/System.err: at com.wattthis.reflowmate.App$$ExternalSyntheticLambda0.onVmViolation(Unknown Source:0)
W/System.err: at android.os.StrictMode.lambda$onVmPolicyViolation$3(StrictMode.java:2462)
W/System.err: at android.os.StrictMode$$ExternalSyntheticLambda3.run(Unknown Source:4)
W/System.err: at android.os.Handler.handleCallback(Handler.java:942)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err: at android.os.Looper.loopOnce(Looper.java:201)
W/System.err: at android.os.Looper.loop(Looper.java:288)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7898)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I audited my code, and don't see any streams or observers, that are not being properly closed.
The error is perfectly reproducible.
I just open the app, and leave it open on the main Activity for 30 seconds. I don't touch the phone at all.
After 30 seconds, when garbage collection comes around, this error appear.
Anyone have any idea on how I can get more information about what is causing this issue?