Bug 60416 - Reduce Hyperlink memory consumption in SXSSF
Summary: Reduce Hyperlink memory consumption in SXSSF
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 60723 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-11-24 21:13 UTC by Javen O'Neal
Modified: 2017-02-10 22:04 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Javen O'Neal 2016-11-24 21:13:37 UTC
From https://lists.apache.org/thread.html/b59a525b6a4dbea9de4d138952c0ab2629c528423f19b363d3434452@%3Cuser.poi.apache.org%3E

Subject: Too much memory is used by a hyperlink in a spreadsheet
Author: Dmitry Katsubo

Memory consumption can be reduced by delaying when new CTHyperlink objects are created until writing the hyperlinks out to <hyperlinks> after <sheetData/> in <worksheet>.
Comment 1 Javen O'Neal 2016-11-24 21:17:25 UTC
Applied Dmitry's patch from email (with modification) in r1771231.
Comment 2 Javen O'Neal 2016-11-24 21:34:32 UTC
Update SXSSF how-to.html to mention that hyperlinks may use a lot of memory in r1771233.
Comment 3 Dmitry 2016-11-25 00:24:26 UTC
The patch is just a minor drop into the sea… more fundamental solution is needed. As complete solution also involves other objects like comments and regions, perhaps the ultimate goal is difficult to achieve. However I think that hyperlinks are potentially used mostly. Javen, what kind of workarounds do you think are feasible at the moment?
Comment 4 Dominik Stadler 2017-02-10 22:04:32 UTC
*** Bug 60723 has been marked as a duplicate of this bug. ***
Comment 5 Dominik Stadler 2017-02-10 22:04:56 UTC
Simple code-sample from the duplicated bug:

-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);
    link.setAddress("http://yoururl.com");
    cell.setHyperlink(link);
}
//then code to write to file.