Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing Heap Size on Linux Machines

I work on Ubuntu desktop machine and I'd like to increase heap size for Java. The RAM is 16GB and the current Max Heap Size is 3GB

I checked this post post Increasing Tomcat Heap Size

Not much found about Ubuntu, so I tried this command:

java -Xmx10000m -X2000m -XshowSettings:all

and the result is:

Min Heap Size: 1.95G
Max Heap Size: 9.77G

then sudo gedit /etc/tomcat7/default

and changed this lino to:

JAVA_OPTS="-Djava.awt.headless=true -Xmx10000m -XX:MaxPermSize=2000m" 

but then I restarted the machine an checked the max size using:

java -XshowSettings:all

and this shows:

Max Heap Size (Estimated): 3.80GB

I wanted to take advantage of the high RAM i got (16 GB). Is there anything else i can do?

like image 272
Shadin Avatar asked Sep 01 '14 10:09

Shadin


People also ask

How do I change my heap size in Linux?

On Unix® and Linux® systems: You can set the JVM heap size by specifying CATALINA_OPTS settings in the setenv.sh file (typically located in the /tomcat/bin/ directory). If this file doesn't exist, you should create it in the same directory as the catalina.sh file (also typically located in the /tomcat/bin/ directory).

How can I increase my heap size?

Under the Java tab, select JVM Options. Edit the -Xmx256m option. This option sets the JVM heap size. Set the -Xmx256m option to a higher value, such as Xmx1024m.

How much heap size we can increase?

Maximum heap size is 1/4th of the computer's physical memory or 1 GB (whichever is smaller) by default. The maximum heap size can be overridden using -Xmx.


2 Answers

Changing Tomcat config wont effect all JVM instances to get theses settings. This is not how it works, the setting will be used only to launch JVMs used by Tomcat, not started in the shell.

Look here for permanently changing the heap size.

like image 90
Pawel Pogorzelski Avatar answered Oct 06 '22 00:10

Pawel Pogorzelski


You can use the following code snippet :

java -XX:+PrintFlagsFinal -Xms512m -Xmx1024m -Xss512k -XX:PermSize=64m -XX:MaxPermSize=128m
    -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

In my pc I am getting following output :

    uintx InitialHeapSize                          := 536870912       {product}
    uintx MaxHeapSize                              := 1073741824      {product}
    uintx PermSize                                 := 67108864        {pd product}
    uintx MaxPermSize                              := 134217728       {pd product}
     intx ThreadStackSize                          := 512             {pd product}
like image 42
Christopher Marlowe Avatar answered Oct 06 '22 01:10

Christopher Marlowe