Pergunta

While processing ODS sheet with JOpenDoc API, getting OutOfMemoryError for java heap space. The processing sheet contains 6000 records. As per JProfiler, consuming memory space becoming more if records are more. How to get rid of this error without increasing JVM size with -X arguments. Here is my java code which is causing outofmemory.

SpreadSheet spreadSheet=SpreadSheet.createFromFile(new File("document.ods")); //memory-35 MB
Sheet sheet1=spreadSheet.getSheet(1); // consumed memory - 47 MB
Sheet sheet2=spreadSheet.getSheet(2); // consumed memory - 59 MB
Sheet sheet3=spreadSheet.getSheet(3); // outofmemory error since the default size is 64 MB
Foi útil?

Solução

You need to either increase the memory with -Xmx or reduce your memory usage. For example, do you need all 3 sheets loaded at once? If not, release the reference to it (e.g. sheet1 = null) and the garbage collector will take care of it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top