我在 Surfaceview 中遇到了内存泄漏问题。
我定义了一个从surfaceview 扩展的自定义视图MyView。
int Layout file
<com.andoird.example.MyView
....
....
/>
并在 onCreate() 中设置内容视图;完成活动后。我得到下面的日志;它显示 Surface 视图中存在内存泄漏。
我希望有人可以帮助我解决这个问题。谢谢!
使用安卓 4.2。
日志 1:
08-16 16:29:23.751 E/StrictMode(23220): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
08-16 16:29:23.751 E/StrictMode(23220): java.lang.Throwable: Explicit termination method 'release' not called
08-16 16:29:23.751 E/StrictMode(23220): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
08-16 16:29:23.751 E/StrictMode(23220): at android.view.Surface.<init>(Surface.java:293)
08-16 16:29:23.751 E/StrictMode(23220): at android.view.SurfaceView.<init>(SurfaceView.java:101)
日志 2
08-16 16:29:23.751 E/StrictMode(23220): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
08-16 16:29:23.751 E/StrictMode(23220): java.lang.Throwable: Explicit termination method 'release' not called
08-16 16:29:23.751 E/StrictMode(23220): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
08-16 16:29:23.751 E/StrictMode(23220): at android.view.Surface.<init>(Surface.java:293)
08-16 16:29:23.751 E/StrictMode(23220): at android.view.SurfaceView.<init>(SurfaceView.java:102)