Heap size error

Hello,

I keep getting an error when i initialize this:

public static int[]   ranks = new int[32487834];
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

I've already set ( 'Settings' -> 'Compiler' -> 'Java Compiler' ->) 'Maximum Heap Size' to 512mb but it doesn't help.
Am i doing something wrong here?

Thanks in advance

3 comments
Comment actions Permalink

You need to change the heap size of the launch configuration, not the
compiler settings.

0
Comment actions Permalink

I hope that you're using a 64-bit JVM and have plenty of RAM on your box. I personally use IntelliJ IDEA 9 under Ubuntu Linux 9.10 (64 bit version). The 32-bit OSs and JVMs have limitations as to how large a heap they can address. Theoretically the max they can address is 2 ** 32 which is approx 4 GB.


In your code you are attempting to allocate a fairly large array and should allocate a much larger heap size. The configuration file for heap sizes and other JVM settings (not the javac compiler as you are trying to set) is in $IDEA_HOME/bin/idea.vmoptions. This of course is in a Linux environment.


Your best bet is to download the VMOptions plugin, restart IDEA and then set the value of -Xmx to a large value - say 768m or 1024m. You do this by restarting IDEA and then click on settings and in the left panel select the new entry IDEA VM Options (shows up after downloading the VMOptions plugin). This will work across platforms - Windows, MacOS and Linux.

See attached screen dumps for additional context in case you are confused.



Attachment(s):
vmoptions.tiff
plugins.tiff
0
Comment actions Permalink

Hey,

Thanks for the info, I guess thats the way to do it.
It doesn't seem to work in my case though, w/e I try. But thanks for the help anyway

0

Please sign in to leave a comment.