Question

I noticed that whenever a thread that runs with a Looper object is finished (i.e. Looper.quit() is called), some files remain open (3 files usually). You can see that by running "adb shell ls /proc//fd | wc -l" This happens because the MessageQueue inside Looper is never freed, although it's never used. Only if I call the finalize() method on the MessageQueue, then these files are freed. The files may remain open hours after the thread is finished. This causes a problem when these threads run in system process because there are many open files already, and I can't exceed the 1024 file boundary. (BTW even when I call System.gc() it doesn't finalize MessageQueue)

Is there anyway (without using reflection) to have MessageQueue finalize method invoked? It seems to me like a bug in Android that the GC doesn't do it by itself even when the number of open files is big.

Thanks

Was it helpful?

Solution

@NitroG42 as it turns out someone beat me to it and posted this bug almost a year ago. It is currently assigned to JBQ. You can find the bug report here: http://code.google.com/p/android/issues/detail?id=41645&q=messagequeue&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top