Norbygyerek / rl-viz

Automatically exported from code.google.com/p/rl-viz
Apache License 2.0
0 stars 0 forks source link

EpisodeLogger in RLVizLib opens lots of files. #39

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The EpisodeLogger can crash the JVM sometimes with "too many files open" 
messages.

This is odd.  I know that the logger doesn't cleanup its temp files until the 
JVM exits, but it should 
at least not have the files open.

Perhaps closing the BufferedWriter is not enough, and we need to close the 
actual FileWriter that it 
wraps.  Or maybe there is a small bug elsewhere in that code.   Or maybe just 
creating too many 
files is the problem. 

Original issue reported on code.google.com by brian.ta...@gmail.com on 7 May 2009 at 4:51

GoogleCodeExporter commented 9 years ago
This might have to do with the OS and its resource limits (open files). Eg. if 
you're
running linux you could try checkin' out these:

http://dev.eclipse.org/newslists/news.eclipse.platform/msg66465.html
http://uw713doc.sco.com/en/man/html.1/ulimit.1.html

hope this helps..

Original comment by idaroglou@gmail.com on 10 May 2009 at 10:13

GoogleCodeExporter commented 9 years ago
I think I've found the culprit:

private void makeTheFile() {
        try {
            theLogFile = File.createTempFile("episode", "log");

            //**** you should probably call: theLogFile.close()  here..   

            //Make sure the file doesn't outlive the program's life
            theLogFile.deleteOnExit();
        } catch (IOException ex) {
            System.err.println("Error ::was unable to create temporary log file in
EpisodeLogger. Suppressing further log messages after Exception printout.");
            System.err.println(ex);
            failedWithError = true;
        }
}

I'm not quite sure whether File.createTempFile closes the newly generated file
descriptor, but in case it doesn't, that's what might explain why the system 
runs out
of available file descriptors (too many open files).

Original comment by idaroglou@gmail.com on 9 Jun 2009 at 2:17