1

Possible Duplicates:
java.lang.OutOfMemoryError: Java heap space
How to deal with “java.lang.OutOfMemoryError: Java heap space” error (64MB heap size)

Could you please tell me how could I increase the java internal heap memory?

Community
  • 1
  • 1
Simon
  • 4,999
  • 21
  • 69
  • 97
  • 9
    I can google that in less than 10 seconds. Try the `-Xmx` option. – svens Mar 25 '11 at 15:23
  • Look and you shall [find](http://stackoverflow.com/questions/1596009/java-lang-outofmemoryerror-java-heap-space). – mre Mar 25 '11 at 15:24

2 Answers2

6

Use java -Xms<initial heap size> -Xmx<maximum heap size>

From the manual page:

This value must be a multiple of 1024 greater than 2 MB. Append the letter k or K to indicate kilobytes, the letter m or M to indicate megabytes, the letter g or G to indicate gigabytes, or the letter t or T to indicate terabytes.

Oswald
  • 31,254
  • 3
  • 43
  • 68
1

Probably you meant increasing the initial or maximum heap memory that the JVM can allocate. This can only be done at the startup time (i-e when your JVM starts up).

JVM accepts argument, often called jvmargs, that let you control various aspects of the JVM instance. For specifying minimum (starting) and maximum heap memory, you can use -Xms and Xmx jvmargs.

The actual process of specifying jvmargs vary depending on how are you launching your java program. If you are launching your program via command-line you can use following pattern:

java -Xms<initial> -Xmx<maximum> <mainClass> <args>

The size can be specified in MB or GB, for example:

java -Xms256M -Xmx2G ...

Tahir Akhtar
  • 11,385
  • 7
  • 42
  • 69