JAVA_OPTS for increasing heap size

Go To


I want to increase my Heap size. How can I use JAVA_OPTS for doing so.I am getting the following error may be this is because of low heap size

java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOfRange(
    at java.lang.String.<init>(
    at java.lang.StringBuilder.toString(
2012-04-04 00:42
by dead programmer
@AmitBhargava yes after reading i asked this question. I am building code on command line. so I want to set this variable globally Do you know how to set this in enviroment(exports) - dead programmer 2012-04-04 00:48
Not sure how to do this in Android, but in normal java you can set these options while using the 'java' command - Chetter Hummin 2012-04-04 00:50


You should be able to use the information found in this post.


where zzz is your minimum size.


where zzz is your maximum size.

JAVA_OPTS="-Xms128m -Xmx512m"

You can find more info on VM args here.

How to set it globally in your environment depends on your operating system. Which OS are you using?

EDIT: I see the "ubuntu" tag now.

You should just be able to put the JAVA_OPTs line in etc/environment. Once you modify etc/environment, you'll have to log out and back in for the updated environment variables to take effect.

2012-04-04 00:46
by Jon O
Is there a full form of OPTs? I mean is it simply shortened form of 'OPtional parameTers' or anything else? We need to set several OPTs like for Maven and Catalina, we opts set for them also. I know the purpose. I just want to know it's full form. Thanks in advance - Archit Kapoor 2015-10-21 07:56
If I had to guess, I'd say it's just shorthand for "options. - Jon O 2015-10-22 15:46
Fine. 'OPTs' looks cool for 'Options'. Thanks Jon once again. : - Archit Kapoor 2015-10-27 06:35