From af1e11b849ea527f4b1b1695924ce42cc9d7f670 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 23 Mar 2010 15:31:21 -0700 Subject: one step toward fixing [2501808] sapphire: OOM in GPU Surface area when a surface was returned from a remote process through the binder we would leak its resources until a GC happened. implement writeToParcel to release the source when PARCELABLE_WRITE_RETURN_VALUE is set Change-Id: I6a9fa369b0d164a9ca1229b8a2944d3c132a3720 --- core/jni/android_view_Surface.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/jni') diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index 060ca50..ed26cbe 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -35,6 +35,11 @@ namespace android { +enum { + // should match Parcelable.java + PARCELABLE_WRITE_RETURN_VALUE = 0x0001 +}; + // ---------------------------------------------------------------------------- static const char* const OutOfResourcesException = @@ -612,6 +617,9 @@ static void Surface_writeToParcel( const sp& control(getSurfaceControl(env, clazz)); SurfaceControl::writeSurfaceToParcel(control, parcel); + if (flags & PARCELABLE_WRITE_RETURN_VALUE) { + setSurfaceControl(env, clazz, 0); + } } // ---------------------------------------------------------------------------- -- cgit v1.1