Submitted On 18-AUG-2002
mthornton
Of course you CAN fix it. You would need to process
deleteOnExit actions after all java code has stopped (and
thus no longer using mapped buffers), and just release any
remaining mappings at this point.
Submitted On 04-DEC-2003
KornySietsma
It would be a start, to give us a method to un-map a
mappedbytebuffer manually. There appears to be no way to
do this without waiting for it to be garbage collected, which
makes this feature all but unusable.
Note that bug 4469299 seems to be unavailable in the bug
parade.
Submitted On 25-MAR-2004
schleinm
The evaluation is INCORRECT: please see the section of this
MSDN article entitled "Unmapping a View of a Memory-Mapped File"
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngenlib/html/msdn_manamemo.asp)
... the delete() method ought to unmap this automatically,
then delete!
ALSO...
The best "workaround" I can come up with involves the following:
- close the channel
- rename the file (maybe use the createTempFile method)
- call deleteOnExit on the renamed File object
... maybe this permits renaming to a different storage
device, which might keep local disk utilization to a minimum.
Submitted On 11-APR-2006
joco
This should really be fixed if you ask me.
Why not give is a close method on the Bufffer. Which does the same as the GC does when it cleans it up
Doing something with deleteOnExit is stupid in myeyes because when does it exit? I can have an op open 8h or even 24h.
this seems a bit of a problem that is on more places like the ClassLoader problem in jar files that also keeps files open... Because UrlConnection doesn't have a disconnect() I do think that these kind of things java is just wrong. Just let me cleanup my mess... Let the GC just cleanup memory anything io related should be closeable for a developer.
Submitted On 02-JUN-2006
Callmeier
This should really be fixed. It makes memory mapped IO unusable for real-world projects.
Submitted On 17-JUL-2006
Please change the affected Java VM's list to 1.5 - it is still there on build 1.5.0_07-b03 for Windows.
Submitted On 10-DEC-2007
maslyak
So "Write once, run anywhere" not works :(
Submitted On 04-MAR-2008
Abhiruka
The only way i founed was to put the data into a byte array and convert it back to a ByteBuffer.
Submitted On 11-AUG-2008
Yubin_Z
A work around: you can unmap by clean method of class, then delete. See below.
public void unmap(final Object buffer) throws Exception {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
Method getCleanerMethod = buffer.getClass()
.getMethod("cleaner", new Class[0]);
getCleanerMethod.setAccessible(true);
sun.misc.Cleaner cleaner = (sun.misc.Cleaner)
getCleanerMethod.invoke(buffer, new Object[0]);
cleaner.clean();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
});
}
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|