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!
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 ...
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!