How to increase Java HEAP SIZE? Getting java.lang.OutOfMemoryError: Java heap space

No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.

How to increase Java HEAP SIZE? Getting this exception:

java.lang.OutOfMemoryError: Java heap space 

at runtime when trying to execute this line of code:

 byte[] data = new byte[cols * rows * elemSize];

in the main thread (console application).

Environment: Win32 (Windows XP SP3 32 bit, 4 Gb of physical RAM):

java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

How can I increase Heap Size allocated by Java runtime? Thanks!


1 Answer - total earned - 0 BTC ($0 USD)

Everyone, even non-registered users could send Bitcoin Tips to YOU if they are inspired by your answer!

You could provide extra options in your command line that launches java.exe . Some of these options allow you to specify HEAP SIZE:

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size

For example:

java.exe -Xmx2048m .... myJarFile.jar ...

Post Answer

Top 3 Tippers
Recent Tips

Will Bitcoin Tipping become a new Internet Culture?

Please share our story! THANK YOU!