For those of you that do not what JCIFS is, it is a Java library which helps you deal with SMB Files in a way very similar to handling normal local File objects. You can list files, open input streams, delete, rename and some other operations.
Recently I was working with this library, specifically building small search tool, which crawls the directories you specify and then return the results. Apparently I was having problems with something that many people tend to overlook, or forget about. Handles originating from my java program never seemed to close.
As you can see, many applications have a few hundreds, including the JVM I have running (see screenshot). So the other day I was testing memory and CPU usage, and they were pretty much under control, until I had a look at the handles column. I began testing small directories, containing less than 30 or so items in total. The handle count rose but it was negligible, since it was at maybe 50 and maybe rose to seventy something. I did not notice since a number of handles might be opened by the JVM and not my code so I ignored it.
After the initial tests, I thought some heavier directory should be crawled, so I pointed it to the desktop, which contains thousands of files (within sub directories obviously, not even a 100" TV could have a 1000 icons on the desktop :P). So again, I fired up the program and bam! I had over 15000 handles, which is absolutely unacceptable.
Practically I have found no solution to this, yet. I really would like to know if any one has had this problem, because as far as I know, there are no methods that close the connection. You can only close streams, and that's OK, but what should I close if I am calling list() or listFiles()?
No comments:
Post a Comment