Message2664

Author cgroves
Recipients
Date 2007-03-09.17:35:09
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Unfortunately, this will cause a memory leak if the user isn't closing files.  The Observable class IOShutdownHook is extending holds onto a hard reference to everything that's observing it(the FileWrapper), and the FileWrappers are only removed from the IOShutdownHook when they're closed, so they'll stay resident in memory even if all of the program's references go out of scope.

Perhaps using a java.lang.ref.WeakReference to wrap the FileWrapper in the IOShutdown hook could keep the hook from holding it in memory, and then adding a finalizer to perform the close on the file wrapper would solve the problem.
History
Date User Action Args
2008-02-20 17:18:40adminlinkissue1669597 messages
2008-02-20 17:18:40admincreate