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

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

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!

Tags:

1 Answer

1
=
0
=
$0
Internet users could send Bitcoin Tips to you if they like 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 ...
SEND BITCOIN TIPS
0

Too many commands? Learning new syntax?

FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with FavScripts.com!

Post Answer