-
Notifications
You must be signed in to change notification settings - Fork 808
Closed
Description
Environment:
- Java 21
- Apache POI 5.4.0
Description:
When using Apache POI to export an XLSX file containing a large number of images, the program encounters an OOM error.
To mitigate the memory issue, I added the following configuration:
static {
ZipPackage.setUseTempFilePackageParts(true);
}
This configuration successfully resolved the OOM problem, but introduced a new issue:
- A large number of temporary files are created during the XLSX file generation process
- These temporary files are not automatically deleted after the program finishes
- Frequent exports cause temporary files to accumulate, eventually exhausting container disk space
Expected Result:
- Provide an automatic cleanup mechanism for temporary files, or release the related temporary file resources when the
Workbookis closed - If cleanup cannot be done on close, in multi-threaded scenarios, generate separate temporary file directories for each file to distinguish them and safely clean up
Steps to Reproduce:
- Create an export logic for an XLSX file containing many images
- Enable
ZipPackage.setUseTempFilePackageParts(true) - Repeatedly perform the export operation and observe the temporary file directory (e.g.,
/tmp)
Impact:
- A large number of temporary files occupy disk space, potentially exhausting container storage
Temporary Workaround & Limitations:
- Manually clean up temporary files, but with the following issues:
- In a multi-threaded environment, all threads write temporary files to the same directory
- Cannot distinguish between temporary files from completed exports and those still being generated
- Deleting files blindly may corrupt files that are still being created
Metadata
Metadata
Assignees
Labels
No labels