java -Xms256M does not set the minimum heap to 256M
Hi,
I am running the same java class with two different jvms. One Sun JVM 1.5.0_12 and the other jrockit JVM 1.5.0_10.
The command I am using is something like this
java -Xms256m -Xmx256m -cp $CLASSPATH com.test.MainClass
I run this command and then check the memory utilization with the help of top. When I use the jrockit jvm, I see the memory utilized by the process around 290Mb that is in line with the minimum heap size. When I use the Sun JVM, the memory utilized by the process is around 30Mb.
How do I get the Sun JVM to use the minimum heap size defined?
Thanks,
Joel
[626 byte] By [
Joela] at [2007-11-27 10:18:42]

# 1
> I am running the same java class with two different jvms.
> One Sun JVM 1.5.0_12 and the other jrockit JVM 1.5.0_10.
And you are on Linux?
What kernel?
> I run this command and then check the memory utilization with the help of top.
Maybe 'top' reports memory actually used rather than memory granted?
What do Runtime.maxMemory() and Runtime.totalMemory() report?
# 2
The linux version is RHEL 4.0 and the kernel version is 2.4.21
> Maybe 'top' reports memory actually used rather than memory granted?
If top shows the memory used instead of the memory granted, then jrockit should also have the same issue. But when I run with jrockit, the memory utilization shows 256Mb+.
Joela at 2007-7-28 16:53:08 >

# 3
I checked the Runtime.maxMemory and Runtime.totalMemory
For Sun JVM, Runtime.maxMemory and Runtime.totalMemory are 266403840
For Jrockit JVM, Runtime.maxMemory and Runtime.totalMemory are 268435456
This proves that the Xmx value is being considered. Does a totalMemory of around 256M prove that the Xms is being considered?
Why is all of the 256M not showing up in top as physical memory for the Sun JVM whereas it is showing up for the Jrockit JVM?
Joela at 2007-7-28 16:53:08 >

# 4
If you want to see how large the Sun VM thinks the heap is, run your test with
"-XX:+PrintGCDetails -XX:+PrintHeapAtGC" and run the test long enough to
get a GC. You'll see information such as
Heap
def new generationtotal 26240K, used 934K [0xe8000000, 0xe9c70000, 0xe9c70000)
eden space 23360K,4% used [0xe8000000, 0xe80e9a20, 0xe96d0000)
from space 2880K,0% used [0xe96d0000, 0xe96d0000, 0xe99a0000)
tospace 2880K,0% used [0xe99a0000, 0xe99a0000, 0xe9c70000)
tenured generationtotal 233024K, used 0K [0xe9c70000, 0xf8000000, 0xf8000000)
the space 233024K,0% used [0xe9c70000, 0xe9c70000, 0xe9c70200, 0xf8000000)
compacting perm gen total 12288K, used 1649K [0xf8000000, 0xf8c00000, 0xfc000000)
the space 12288K, 13% used [0xf8000000, 0xf819c490, 0xf819c600, 0xf8c00000)
The sum of the totals for "def new generation" and "tenured generation" will give you
the size of the heap as the VM sees it.
# 5
> If top shows the memory used instead of the memory
> granted, then jrockit should also have the same
> issue.
Nope.
Different VMs, different solutions to how memory is used via the OS.