OSDN Git Service

Enable native tracking for RS contexts to improve GC behavior.
authorTim Murray <timmurray@google.com>
Fri, 12 Dec 2014 19:34:48 +0000 (11:34 -0800)
committerTim Murray <timmurray@google.com>
Fri, 12 Dec 2014 21:30:15 +0000 (13:30 -0800)
This should prevent apps from leaking RS contexts as easily.

bug 18579193

Change-Id: I2d943ce4443ce7cb90ebdd3dd37d338eda6df3a2

rs/java/android/renderscript/RenderScript.java

index 6c5c508..541cce8 100644 (file)
@@ -1184,6 +1184,13 @@ public class RenderScript {
             mApplicationContext = ctx.getApplicationContext();
         }
         mRWLock = new ReentrantReadWriteLock();
+        try {
+            registerNativeAllocation.invoke(sRuntime, 4 * 1024 * 1024 * 1024); // 4MB for GC sake
+        } catch (Exception e) {
+            Log.e(RenderScript.LOG_TAG, "Couldn't invoke registerNativeAllocation:" + e);
+            throw new RSRuntimeException("Couldn't invoke registerNativeAllocation:" + e);
+        }
+
     }
 
     /**