You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/03/11 17:32:52 UTC

[Bug 59166] New: util TempFile could cause memory leak

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

            Bug ID: 59166
           Summary: util TempFile could cause memory leak
           Product: POI
           Version: 3.13-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: kong.shijun@gmail.com

Currently implementation will register not only temp directory, but also
individual files to java.io.DeleteOnExitHook via java.io.File#deleteOnExit

For some long running applications which generate tons of files via POI, it
will create huge garbage to the hook, even the actual temp files have already
been deleted. 

Today, there is only one system property flag "poi.keep.tmp.files". If turn
off, both temp directory and temp files won't be deleted on exit. Can we always
ignore files, and only register temp directory?

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166
Bug 59166 depends on bug 59788, which changed state.

Bug 59788 Summary: Create temporary directory with POI
https://bz.apache.org/bugzilla/show_bug.cgi?id=59788

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #3 from Javen O'Neal <on...@apache.org> ---
None of the POI unit tests run long enough to experience the problems you're
experiencing. While we could register just the directory for deletion on JVM
exit, this strategy seems dangerous if the directory was not empty before
starting or a separate application wrote data to the directory. Under these
conditions, data loss could occur.

Another strategy for long-running processes is to keep a fixed-length queue of
files and delete the files FIFO as the queue overflows.
This would mean not registering deleteOnExit with the JVM, so you would need to
intercept a JVM exit message to delete the files remaining in the queue before
the JVM shut down.

You could also implement a strategy that deletes all temp files that have been
created. This is essentially the same as above using a variable-length set that
never implicitly deletes files.

I don't think any of these strategies are safe enough to implement without
getting into trouble: either leaving temp files behind or accidentally deleting
files that shouldn't have been deleted. If you have a better
TempFileCreationStrategy that would appeal to many users, feel free to re-open
this bug with the corresponding patch.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Javen O'Neal <on...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Depends on|                            |59788
         Resolution|WONTFIX                     |---

--- Comment #4 from Javen O'Neal <on...@apache.org> ---
With the changes from bug 59788, the strategy described in Comment 0 could be
accomplished by:

File tempDir =
DefaultTempFileCreationStrategy.createTempDirectory("registeredDirectory");
for (String f : filesToAdd) {
    createSomeFile(new File(tempDir, f));
}

I updated the documentation in r1751190 to make the purpose of
DefaultTempFileCreationStrategy clearer and suggestions for other
TempFileCreationStrategy's that may be useful outside of the POI project.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
I am setting this to Enhancement for now as you can already implement your own
TempFileCreationStrategy, which allows to do this differently if this is
actually a problem for your application.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59166] util TempFile could cause memory leak

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59166

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Would you be able to put together a patch together with some unit-tests that
would address and verify this?

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org