Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
File Descriptors Leak
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Robert Olofsson, post: 547870"] : I wanted to ask if I have to explicitly close all open files (using : FileInputStream.close and similar methods) in order to free : file-descriptors, or is it taken care of automatically by the GC : whenever it runs? Yes, you have to close/dispose/flush lots of things in java. Streams, Graphics, Images, windows... Java may have a Garbage Collector, but system resources still has to be handled. Some of the resources have finilizer methods that clean up things nicely, some things like oracles prepared statements however will not clean themself up at all ( => if you dont close you run out of cursors in the database after a while). Basically this means that you have to write code that looks like: InputStream is = null; try { is = new FileInputStream (...); .... } finally { if (is != null) is.close (); } Add additional try/catch as needed. By having a finally you pass your close-code before exiting even if an exception is thrown. /robo [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
File Descriptors Leak
Top