1

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
Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413
janasainik
  • 811
  • 5
  • 20
  • 40
  • Is there a reason for avoiding using the -X flags? – Jason Feb 29 '12 at 03:03
  • 3
    Um, Stop using all the memory? If you refuse to increase the memory available to the JVM to something that resembles what you need, that's your other option. Only deal with one `Sheet` at a time. – Brian Roach Feb 29 '12 at 03:03
  • @Jason: Yes, since the sheet records may increase gradually. in that case there is no fixed heap memory to assign. As i told you that heap memory is increasing more if records count is more. – janasainik Feb 29 '12 at 03:11
  • 1
    64 MB? are you living in 90s? :) use -Xmx to set your memory. – Rudy Feb 29 '12 at 03:19
  • ^^ This is a poor reason not to increase the heap usage. How is the heap size increased when the sheet count increases? – Amir Afghani Feb 29 '12 at 03:19
  • edited in different language? – javaCity Feb 29 '12 at 03:40

1 Answers1

2

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.

svachalek
  • 1,166
  • 8
  • 18