summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/RenderScript.java
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2013-04-13 19:48:36 -0700
committerJason Sams <jsams@google.com>2013-04-14 02:56:03 +0000
commit9bf189228fdb0ec14b284f8bd543d5f9137997cc (patch)
treebe5ebeea9340aa4c718cae968e34d3d9cab34e8e /graphics/java/android/renderscript/RenderScript.java
parent02d56d90e01e20db8424de94a14fe59dc94f19c0 (diff)
Revert GC thread changes
This is not quite a straight revery, some manual edits were necessary. The original CL didn't undergo sufficient design review or testing. Revert until the regressions can be sorted out. Bug 8585185 This reverts commit 6dacf8355a0692b52c49f603f43317772cb36175 This reverts commit f8c033db1edf36a0ab09568c3142054f0be2d1a1 Change-Id: Ie7215bdf881332e822603547e92f810f595077fc
Diffstat (limited to 'graphics/java/android/renderscript/RenderScript.java')
-rw-r--r--graphics/java/android/renderscript/RenderScript.java72
1 files changed, 0 insertions, 72 deletions
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 33639dc57d4f..6f614c3767e9 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -18,9 +18,7 @@ package android.renderscript;
import java.io.File;
import java.lang.reflect.Field;
-import java.util.concurrent.locks.*;
-import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -804,8 +802,6 @@ public class RenderScript {
int mContext;
@SuppressWarnings({"FieldCanBeLocal"})
MessageThread mMessageThread;
- GCThread mGCThread;
-
Element mElement_U8;
Element mElement_I8;
@@ -1095,60 +1091,6 @@ public class RenderScript {
}
}
- static class GCThread extends Thread {
- RenderScript mRS;
- boolean mRun = true;
-
- long currentSize = 0;
- long targetSize; // call System.gc after 512MB of allocs
-
- final Lock lock = new ReentrantLock();
- final Condition cond = lock.newCondition();
-
- GCThread(RenderScript rs) {
- super("RSGCThread");
- mRS = rs;
-
- }
-
- public void run() {
- ActivityManager am = (ActivityManager)mRS.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
- ActivityManager.MemoryInfo meminfo = new ActivityManager.MemoryInfo();
- am.getMemoryInfo(meminfo);
- targetSize = (long)(meminfo.totalMem * .5f);
-
- while(mRun) {
- System.gc();
- lock.lock();
- try {
- cond.awaitUninterruptibly();
- } finally {
- lock.unlock();
- }
- }
-
- Log.d(LOG_TAG, "GCThread exiting.");
- }
-
- public synchronized void addAllocSize(long bytes) {
- currentSize += bytes;
- if (currentSize >= targetSize) {
- lock.lock();
- try {
- cond.signal();
- } finally {
- lock.unlock();
- }
- }
- }
-
- public synchronized void removeAllocSize(long bytes) {
- currentSize -= bytes;
- }
-
- }
-
-
RenderScript(Context ctx) {
if (ctx != null) {
mApplicationContext = ctx.getApplicationContext();
@@ -1171,15 +1113,6 @@ public class RenderScript {
return create(ctx, sdkVersion, ContextType.NORMAL);
}
- void addAllocSizeForGC(int bytes) {
- mGCThread.addAllocSize(bytes);
- }
-
- void removeAllocSizeForGC(int bytes) {
- mGCThread.removeAllocSize(bytes);
- }
-
-
/**
* Create a basic RenderScript context.
*
@@ -1196,9 +1129,7 @@ public class RenderScript {
throw new RSDriverException("Failed to create RS context.");
}
rs.mMessageThread = new MessageThread(rs);
- rs.mGCThread = new GCThread(rs);
rs.mMessageThread.start();
- rs.mGCThread.start();
return rs;
}
@@ -1253,11 +1184,8 @@ public class RenderScript {
validate();
nContextDeinitToClient(mContext);
mMessageThread.mRun = false;
- mGCThread.mRun = false;
- mGCThread.addAllocSize(0);
try {
mMessageThread.join();
- mGCThread.join();
} catch(InterruptedException e) {
}