Reputation: 8153
I am facing some weird memory leak using camera2 api. Tested with https://github.com/googlesamples/android-Camera2Basic adding empty activity to launch the camera activity and close it then launch again, I get following trace:
11-12 12:52:19.506 16069-16078/com.example.android.camera2basic E/StrictMode: 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 'release' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at android.view.Surface.setNativeObjectLocked(Surface.java:511) at android.view.Surface.(Surface.java:179) at com.example.android.camera2basic.Camera2BasicFragment.createCameraPreviewSession(Camera2BasicFragment.java:684) at com.example.android.camera2basic.Camera2BasicFragment.access$400(Camera2BasicFragment.java:74) at com.example.android.camera2basic.Camera2BasicFragment$2.onOpened(Camera2BasicFragment.java:194) at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61) 11-12 12:52:19.506 16069-16078/com.example.android.camera2basic W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
I use
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
Running on LG Nexus 5X, OS 7.1.2
Any ideas if this is something to worry about?
Thanks.
Upvotes: 1
Views: 1443
Reputation: 18097
This is more or less a spurious error, due to the framework handling of Surfaces in some cases.
It is not an issue you can do anything about, but in practice it should not cause you any real memory leaks.
Upvotes: 1