diff options
author | Tim Murray <timmurray@google.com> | 2013-08-22 14:55:26 -0700 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2013-08-23 13:35:19 -0700 |
commit | 2f2472c42be8e80f00019594036744d902e09dcb (patch) | |
tree | 2f36a019cf92994293e66cd54b897ae04c7f4e1d /graphics/java/android/renderscript/Allocation.java | |
parent | 2365745855ac4725949ebe9bae72fdc0613bb94f (diff) |
Add garbage collection hooks
bug 10428172
Change-Id: I6365aa58bbc99aa134e1f261a5819e07a7d70fb0
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 362b58637606..7d05a744a19c 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -61,6 +61,7 @@ public class Allocation extends BaseObj { Bitmap mBitmap; int mUsage; Allocation mAdaptedAllocation; + int mSize; boolean mConstrainedLOD; boolean mConstrainedFace; @@ -268,10 +269,22 @@ public class Allocation extends BaseObj { mType = t; mUsage = usage; + mSize = mType.getCount() * mType.getElement().getBytesSize(); if (t != null) { updateCacheInfo(t); } + try { + RenderScript.registerNativeAllocation.invoke(RenderScript.sRuntime, mSize); + } catch (Exception e) { + Log.e(RenderScript.LOG_TAG, "Couldn't invoke registerNativeAllocation:" + e); + throw new RSRuntimeException("Couldn't invoke registerNativeAllocation:" + e); + } + } + + protected void finalize() throws Throwable { + RenderScript.registerNativeFree.invoke(RenderScript.sRuntime, mSize); + super.finalize(); } private void validateIsInt32() { |