title: How to fix memory leak in SurfaceView
body: <p>I met a memory leak issue in surfaceview.</p>
  
  <p>I define a custom view MyView which extends from surfaceview.</p>
  
  <pre><code>int Layout file 
  &lt;com.andoird.example.MyView
  ....
  ....
  /&gt;
  </code></pre>
  
  <p>and setContentView in onCreate();
  after finish the Activity.
  I get the log below;
  It show the there are memory leak in Surface view.</p>
  
  <p>I hope someone can help me to resolve this. Thank you!</p>
  
  <p>use Android 4.2.</p>
  
  <p>Log 1:</p>
  
  <pre><code>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.&lt;init&gt;(Surface.java:293)
  08-16 16:29:23.751 E/StrictMode(23220):     at android.view.SurfaceView.&lt;init&gt;(SurfaceView.java:101)
  </code></pre>
  
  <p>Log 2</p>
  
  <pre><code>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.&lt;init&gt;(Surface.java:293)
  08-16 16:29:23.751 E/StrictMode(23220):     at android.view.SurfaceView.&lt;init&gt;(SurfaceView.java:102)
  </code></pre>