How to increase JAVA Heap Size?
You could use java -Xmx4096m
in order to set your heap to 4 GB.
you could then add export _JAVA_OPTIONS=-Xmx4096m
to your shell by their (.bashrc, .zshrc) file.
Related videos on Youtube
Program man
It's my passion and job... So I have to work on all flavors of Linux. I am launching my own company very soon in the IT sector. Thank you all for giving support and to start such a good platform for all Linux users. Ubuntu rocks... :) Please feel free to contact me in case of any query on [email protected]
Updated on September 18, 2022Comments
-
Program man over 1 year
I need to increase the default java heap size to get OpenNMS Linkd service running smoothly, and fortunately I have 4/5 of my total installed memory free at any given time even when their is maximum load on the server. still java is not performing to it's bast. hence I need to increase the default java heap size.
Can anyone tell me how to do it?
I'm using Ubuntu 12.04 lts & total memory installed is 16 GB out of which generally 2GB to 4GB is used.
I have already checked below questions and they did not help me resolve my issue.
How to increase memory allocated to java? java.lang.OutOfMemoryError: Java heap space
How to increase memory allocated to java? java.lang.OutOfMemoryError: Java heap space
Please feel free to edit or comment for any additional details required.
-
josh.thomson about 9 yearsHow do you check the current configuration of the heap size?
-
Taylor Ramirez about 9 yearsif you run
java -XshowSettings:vm
, near the top it should say something like this "Max. Heap Size (Estimated): 2.60G" -
josh.thomson about 9 yearsWould increasing the amount of RAM on the server remove the heap error? Here's my scenario: askubuntu.com/questions/611685/…
-
Taylor Ramirez about 9 yearsdepends if the heap is getting too big for the main memory, like if the heap hit 2GB and the RAM is only two GB you'd most likely get an error before that because there are other things in memory. now if the error is the program needs a bigger heap and Java has say 0.5GB as the max heap size and you need 1GB for the program, then it is more of a setting error than a hardware issue.
-
josh.thomson about 9 yearsAh! here's my result: Max. Heap Size (Estimated): 494.94M ... So I guess it would be a good idea to increase the Heap Size to around 2GB. After some research I have found out there is a 3GB RAM limit on 32-bit Ubuntu 14.04 LTS systems (with a certain PAE config)... So I increased the RAM to 3GB (networking is working unaffected). I will try increasing the heap and see if that works! -Thanks for your assistance.
-
josh.thomson about 9 yearsI used 'java -Xmx2048m' to set the heap size to 2GB. However, the estimated heap size is still showing '494.94M'. Even after a reboot. ...I have started the script again... so hopefully it will complete this time. I will update with progress.
-
Taylor Ramirez about 9 yearsyou might have to set that in the defaults for Java otherwise you'll have to give it that argument each time.
-
josh.thomson about 9 yearsThanks, I found the command needed :) Link to Thread
-
Taylor Ramirez about 9 yearsThat's good glad to help, also if my answer helped you there is an upvote button there ;)