https://issues.apache.org/bugzilla/show_bug.cgi?id=53780

          Priority: P2
            Bug ID: 53780
          Assignee: [email protected]
           Summary: memory and temporary file leak in SXSSF
          Severity: major
    Classification: Unclassified
                OS: All
          Reporter: [email protected]
          Hardware: All
            Status: NEW
           Version: 3.8
         Component: SXSSF
           Product: POI

Created attachment 29278
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29278&action=edit
patch to fix leaks of memory and temporary files

The current SXSSF implementation leaks memory by calling File.deleteOnExit().
It is recommended that the deleteOnExit method should never be called in a
persistent application; see discussion here:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4513817

Additionally, temporary files are not cleaned up until the program exits, as
noted in this POI bug:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53493

This patch is submitted as an alternative to the fix proposed in the
aforementioned bug. I'm reporting a separate bug in order to encompass the
additional concern about memory leaks.

Here's how the patch works:
* all calls to deleteOnExit are eliminated.
* the SXSSFWorksheet class walks through all sheets after the output is
written, deleting each associated temporary file immediately.
* close and delete operations are moved into finally blocks, ensuring cleanup
even when an exception causes premature failure.

These changes are vitally important for our high-throughput, persistent server
that will pound out million row Excel spreadsheets all day long. (We've patched
the POI library internally but it would be great to factor these changes into
the distribution.)

I would volunteer to create unit tests for this improvement but there isn't an
existing unit testing framework for the SXSSF component, so far as I can tell.
I'm open to contributing on that front in the future, if there's interest.

Thanks!

-- 
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