Even though I close all files it says "too many open files" :(

Hi,

basically, i use the RandomAccessFile class to write to files. Max I've tried is around 20 files. There is only one file open at any given time.

I have ensured this cos while debuggin I wrote "increment" and "decrement" methods, and ran them after I opened and closed a file respectively. Obviously increment and decrement add 1 and minus 1 respectively from an interger variable instantiated to 0. Increment and decrement are implemented as synchronized methods!

According to my monitoring of my program during run time using the above methods no more than one file is ever open at any time!

However after a while of running my java program crashes with "too many open files" as the error.

I dunno if any of you know what this is but im using Jasper (java interface for sicstus prolog) as part of my java program. Its an academic individual project.

I've racked my brains trying to fix this error but I cant seem to get anywhere.

I thought it could be a bug within netbeans 5 (i test run my program within the netbeans IDE) or it could be a bug in jasper! Or more likely a bug in my code! Im using Java 1.5.

Does anyone have any tips or ideas?

Also, is there a way to monitor the number of files opened by a java process? Im runnin XP!

ANY help would be much appreciated :)

[1348 byte] By [compScienceGuya] at [2007-10-2 20:15:51]
# 1
Maybe you overlooked something in your program. You did not post the releveant code portion. Does maybe watching task manager's handle column help?See also: http://www.sysinternals.com/Utilities/Filemon.html
BIJ001a at 2007-7-13 22:58:11 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
This has been covered. Try searching the forums. IIRC it has to do with the file handles remaining open and closing when the OS wants them to. But there was a fix/workaround.
_dnoyeBa at 2007-7-13 22:58:11 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...