Enormus memory usage.

Skip to first unread message


Jan 19, 2020, 6:49:06 AM1/19/20
to jOpenDocument


I have been using jOpenDocument for some time now, and it behaves in a way that I do not understand.

I have a SpreadSheet with only one non-empty Sheet containing 57495 rows and 476 columns.

Around 80% of the cells are blank, and with no style.

The rest have a small String of 1 to 15 char max.

I have defined 3 custom styles which are used on some of the cells.

This SpreadSheet takes up 2.2MegaBytes on the disk.

I perform the following code on it:

File file = new File("fileName.ods");

Sheet sheet = SpreadSheet.createFromFile(file).getSheet(0);

int rowCount = sheet.getRowCount();

int columnCount = sheet.getColumnCount();

for (int y = 0; y < rowCount; y++)


     for (int x = 0; x < columnCount; x++)

         sheet.getCellAt(x, y);



Now from what I would expect, this code shouldn't really be doing anything at all.

However, it keeps creating a bunch of MutableCell which are never unloaded.

After about 2 minutes, the heap is taking up 4.8GigaBytes of the 6GigaBytes I have allocated it, 4.3GigaBytes of which is actually used.

The program has created about 23 million MutableCell, and about as much Element, Attribute[], AttributeList and ContentList.

It has now reached row 48000.

From then on it slows down significantly, progressing at about 1 row every 5 minutes. GC and CPU usage are both at about 0%.

After about an hour it produces an OutOfMemoryError : Java heap space, even though it has still not reached the 6GigaByte limit.

Could someone please explain this behavior? It seems that any call I make to the getCellAt() method makes the memory consumption explode.

Because of this, I cannot use methods like getCellAt().setStyleName() or getCellAt().merge() in big files, which is a real problem for me.

There is something I don't understand about the getCellAt() method. How would I go about setting the style of a cell, or merging cells in a big file?

Thank you for taking the time to read me.

Guillaume Maillard

Jan 19, 2020, 9:57:10 AM1/19/20
to jopend...@googlegroups.com

getCellAt is a very high level function, it resolves all the information about the cells.
For bulk processing, use low level APIs to manipulate the DOM.



You received this message because you are subscribed to the Google Groups "jOpenDocument" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jopendocumen...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jopendocument/a7430116-12fd-4907-a2b4-b5c6fa8d4766%40googlegroups.com.


Jan 19, 2020, 10:04:50 AM1/19/20
to jOpenDocument
Thank you for your reply Guillaume.

Would you be able to show me an example of how to set the style of a cell at the lowest level possible?

Thanks again!
Reply all
Reply to author
0 new messages