https://bz.apache.org/bugzilla/show_bug.cgi?id=58480

--- Comment #11 from Dominik Stadler <[email protected]> ---
Created attachment 33176
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33176&action=edit
Patch which uses sun.nio stuff to free mapped resources

Hmm, file-leak-detector does not show any open file, also Process Explorer does
not show the file being still opened for the process if I debug and stop before
the place where it fails.

For me even if I do the close() of NPOIFSFileSystem as you suggest, I still get
the error.

It seems we are creating Buffers during reading via NPOIFSFileSystem and these
seem to hold on to resources even if the channel is closed.

Some related discussion on Stackoverflow shows similar problems and lists some
Java bugs involved as well, e.g.
http://stackoverflow.com/questions/3602783/file-access-synchronized-on-java-object,
http://stackoverflow.com/a/5036003/411846 and
http://stackoverflow.com/a/9779181/411846 as well as
http://bugs.java.com/view_bug.do?bug_id=4724038

So the problem seems to be that there is no clean way to free the mapped
buffers!

Finally I found that there is a DirectBuffer.cleaner.clean() method which seems
to free resources that are still held by the ByteBuffer instances, however
DirectBuffer is in package "sun.nio" so it is likely not a good idea to use it,
especially as Oracle announced to ditch all these forbidden packages in Java 9. 

See the attached patch for my current solution, not sure what we need to do
make this a valid solution for POI itself.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to