Bug 60723 - Hyperlink Memory Leak
Summary: Hyperlink Memory Leak
Status: RESOLVED DUPLICATE of bug 60416
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.14-FINAL
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-02-10 19:35 UTC by Matt Jackson
Modified: 2017-02-10 22:04 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Matt Jackson 2017-02-10 19:35:33 UTC
-When writing a million rows to excel, with each row having a hyper link, it causes java to run out of memory. Heap space set to 4GB. write to excel without hyper links ram usage was 160MB, with hyper links it used 4GB and crashed.

-Because a hyperlink object needs to be recreate every time in order for it to work, it ends up eating ram. There doesn't seem to be a way to close hyperlink objects after they are used. 

-example code:
SXSSFWorkbook wb = new SXSSFWorkbook(100);
SXSSFSheet sheet = wb.createSheet();
CreationHelper createHelper = wb.getCreationHelper();
Hyperlink link;
SXSSFRow row;
SXSSFCell cell;
for(int i=0; i<1000000; i++){
    row = sheet.createRow(i);
    cell = row.createCell(1);
    cell.setCellValue("Click Me");
    link = createHelper.createHyperlink(Hyperlink.LINK_URL);
//then code to write to file.
Comment 1 Dominik Stadler 2017-02-10 22:04:32 UTC
We are already discussing this in bug 60416, I will add your code-example there to keep the discussion in one place.

*** This bug has been marked as a duplicate of bug 60416 ***