Remi
Remi

Reputation: 766

Too many open files error - debugging

I often got "Too many open files error" error on my device (HTC Wildfire S, Android 2.3.5.). I already found some topics that I probably have memory leak. The question is how to debug the issue? How to find which process is consuming file descriptors and not releasing it?

My device is not root-ed - so I would like to know how to get information about opened descriptors on not root-ed device. If this is not possible, let me know how to get such data on android emulator.

Upvotes: 5

Views: 9091

Answers (3)

Steve Smith
Steve Smith

Reputation: 2270

You can also run something like

lsof | grep <pid>

to see all the files your app is using. Add | wc -l to the end to get a total.

Upvotes: 0

Viktor Malyi
Viktor Malyi

Reputation: 2386

In order to get number of files opened along with the files themselves you can also use following command:

lsof | grep USER | tee /dev/tty | wc -l

The total number of file opened by USER will be printed at the very end of the output.

Upvotes: 0

R Earle Harris
R Earle Harris

Reputation: 983

I've just been dealing with this. It is (SFAIK) the OS that says "too many open files." On any Unix, run lsof in a terminal. Make that lsof | less because you won't believe how many open files there are. Apps these days are file-crazy.

Anyway, shut down some applications, as many as is convenient, and try again. One of the big culprits is adb itself. I can't tell if it ever closes anything. So if closing some apps didn't help, close Eclipse. Then in a Unix terminal, run skill -9 adb. Other OSes will have other kill tools. But kill adt, which is probably (certainly in Unix) still chugging away in the background after closing Eclipse.

If this doesn't work, get really small; go in there; and close those files by hand.

Upvotes: 3

Related Questions