Issue1669597

classification
Title: fix for IO flush bug
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, wargolem
Priority: normal Keywords: patch

Created on 2007-02-27.00:39:08 by wargolem, last changed 2007-04-23.03:47:22 by cgroves.

Files
File name Uploaded Description Edit Remove
ioflush.txt wargolem, 2007-02-27.00:56:29 IO flush bugfix
Messages
msg2661 (view) Author: Alexander J Smith (wargolem) Date: 2007-02-27.00:39:08
Fixed the problem by adding an Observable object to the Runtime shutdown hooks, which notifies its observers when it runs.  FileWrappers now observe this object and flush when they are notified.  It adds a minimal amount of code to solve the problem.

Authored by Alexander Smith, Eric Dobbs - 2/26/07
msg2662 (view) Author: Alexander J Smith (wargolem) Date: 2007-02-27.00:42:12
File Added: ioflush.txt
msg2663 (view) Author: Alexander J Smith (wargolem) Date: 2007-02-27.00:56:30
File Added: ioflush.txt
msg2664 (view) Author: Charlie Groves (cgroves) Date: 2007-03-09.17:35:09
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.
msg2665 (view) Author: Charlie Groves (cgroves) Date: 2007-04-23.03:47:22
Rejected in favor of http://jython.org/patches/1637931 as it doesn't have a memory leak.
History
Date User Action Args
2007-02-27 00:39:08wargolemcreate