1

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

If I try to increase any of these numbers, I get the following JVM error:

Error occurred during initialization of VM

Could not reserve enough space for object heap

Could not create the Java virtual machine.

How can I solve this OutOfMemoryError problem? (even if I need to cache memory on disk)

Community
  • 1
  • 1
David Portabella
  • 12,390
  • 27
  • 101
  • 182

1 Answers1

4

How much memory does your system have? Are you running windows? You can't create much more than 1G heap with a 32bit windows JVM. If your Xms setting is greater than this limit the JVM will fail to initialize.

JPEG images are compressed. A 100M JPEG is pretty large and will be a lot larger once decompressed by the image io lib. OOM with 1G heap is quite conceivable.

Barry

barry
  • 201
  • 1
  • 4
  • yes, it is a 32bit windows; is there a way to tell JVM to use a file for the heap memory, instead of ram memory (to be able to increase the heap space, even in a 32bit windows)? – David Portabella Apr 22 '12 at 01:47
  • 1
    You can swap space but the size of the heap on a 32-bit system is limited to about 1.2 to 1.5 GB. The most you can access on a 32-bit system in theory is 4 GB (i.e. 2^32) and the limit for Windows is 3.5 GB. The continuous memory you can get is what limits the heap size. BTW: If you exceed your physical memory, your program will slow down by a factor of 10 or more. – Peter Lawrey Apr 22 '12 at 09:48