summaryrefslogtreecommitdiff
path: root/libs/utils/Threads.cpp
diff options
context:
space:
mode:
author Evan JIANG <firstfan@gmail.com> 2008-10-28 01:13:38 +0800
committer Jean-Baptiste Queru <jbq@google.com> 2009-03-04 12:04:07 -0800
commitbfcb2193b3d64a0a2087d66eadf1e20f37e3addd (patch)
treedf39dcd82c5161ba2fa6dc5c4f747b602755e496 /libs/utils/Threads.cpp
parent90329a69f8e26626c3dc51c50a287e47931afe18 (diff)
Fix a FileObserver jni bug.
The path string in FileObserver jni will not be automatically released in the while loop. Then it will cause too many local refs in the ref table. When received too many file changed notifications/events, the process will be killed for "Failed adding to JNI local ref table". Test code: ============================================================= import android.app.Activity; import android.os.Bundle; import android.os.FileObserver; import android.util.Log; import java.io.File; import java.io.IOException; public class TestApp extends Activity { public static final String TAG="TestApp"; FileObserver observer; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); observer=new FileObserver("/tmp"){ @Override public void onEvent(int event, String path) { if(event == FileObserver.CREATE){ Log.e(TAG, "File created [" + path + "]"); }else if(event == FileObserver.DELETE){ Log.e(TAG, "File deleted [" + path + "]"); } } }; observer.startWatching(); File f=new File("/tmp/a.txt"); for (int i=0;i<300;i++) { try { f.createNewFile(); } catch (IOException e) { } f.delete(); } } } ================================================ The last 2 lines of the log: E/dalvikvm( 705): Failed adding to JNI local ref table (has 512 entries) E/dalvikvm( 705): VM aborting
Diffstat (limited to 'libs/utils/Threads.cpp')
0 files changed, 0 insertions, 0 deletions