https://issues.apache.org/bugzilla/show_bug.cgi?id=56625
Bug ID: 56625
Summary: Constructor for HSSFWorkbook leads to memory leak
Product: POI
Version: 3.8
Hardware: PC
OS: Linux
Status: NEW
Severity: critical
Priority: P2
Component: HSSF
Assignee: [email protected]
Reporter: [email protected]
The constructor for org.apache.poi.hssf.usermodel.HSSFWorkbook
public HSSFWorkbook(DirectoryNode directory, boolean preserveNodes) throws
IOException
creates a DocumentInputStream instance, but never gets around to closing it.
So even though the input stream is garbage collected, the resource allocated by
the OS to the JVM remains. This causes a "Too many open files" error
eventually, after the ulimit for the user has been reached.
<b>Environment Details :</b>
JVM ->
javac 1.6.0_31
JRE ->
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
<b>Steps to reproduce :</b>
1) Do an lsof -p <jvm process id> before reading the xls file
2) Use code below :
Workbook workbook = WorkbookFactory.create(file);
to get a workbook.
3) Finish reading the xls file. Do a few operations on the workbook and then
leave it to be garbage collected.
4) Try and run a System.gc() to collect the input stream. Can monitor this
using JProfiler.
5) Do lsof -p <jvm process id>. The file is still visible in lsof :(
<b>Possible fixes :</b>
Emulate the behavior for "java.io.FileInputStream" by overriding finalize()
method in "org.apache.poi.poifs.filesystem.DocumentInputStream" .
--
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]