0

Using: -Xms1000M -Xmx4000M -mx1000m I still get a java.lang.OutOfMemoryError: Java heap space

I am using the jai-imageio library to read a 100Mb JPEG2000 file, and it may need more than 1Gb heap space once decompressed by the imageio lib. I am using a 32bit windows JVM, so I can't create more than 1G heap space.

See this post: java- OutOfMemoryError with -Xms1000M -Xmx4000M -mx1000m

So, is there a way to tell JVM to use a file for the heap memory, instead of ram memory (to be able to have a heap space bigger than 1Gb, even in a 32bit windows)?

Community
  • 1
  • 1
David Portabella
  • 12,390
  • 27
  • 101
  • 182
  • 2
    Not that I know of. Why don't you believe what you've already read? – duffymo Apr 22 '12 at 09:56
  • 3
    Time to switch to 64bit technology. – Mat Apr 22 '12 at 09:56
  • possible duplicate of [java- OutOfMemoryError with -Xms1000M -Xmx4000M -mx1000m](http://stackoverflow.com/questions/10264123/java-outofmemoryerror-with-xms1000m-xmx4000m-mx1000m) – harto Apr 22 '12 at 11:19

1 Answers1

4

This is a limitation of the operating system (and the number of bits you have in your addresses). You need to use a 64-bit OS and a 64-bit JVM.

When you add to the swap space you are allowing the JVM to use this file as swap space. Note: do so can decrease your performance by 10x or more.

You should be able to get a heap of between 1.2 GB and 1.5 GB on 32-bit windows.

A similar question was asked here. How much -XX:MaxPermSize size i can mention for 4GB and 8GB Ram and calculation for this?

Community
  • 1
  • 1
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130