13

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?

Community
  • 1
  • 1
Shadin
  • 1,867
  • 5
  • 26
  • 37

2 Answers2

7

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.

Nicholas K
  • 15,148
  • 7
  • 31
  • 57
  • Thanks. I've read that it's better to set the `Xmx` and `Xms` to the same value. but I'm wondering about `MaxPermSize`. If `Xmx` and `Xms` are 12 GB. and the total RAM is 16 GB. What is the best value for `MaxPermSize` ? – Shadin Sep 02 '14 at 07:40
  • 1
    There's no optimal settings for the heap. All depends on your application. Don't try to allocate as much heap as you can as this can lead to long GC triggered pauses. Google for Java heap guidelines. The same goes for MaxPermSize - you can read more about it here - http://stackoverflow.com/questions/12114174/what-does-xxmaxpermsize-do. – Pawel Pogorzelski Sep 02 '14 at 07:49
5

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}
Christopher Marlowe
  • 2,098
  • 6
  • 38
  • 68