0

When I increase -Xms value on tomcat, the memory usage (from the free -m command) does not change accordingly. The example below shows that increasing its value by 200MB affects memory usage by only ~85MB.

...usr/lib/jvm/jre/bin/java -Xms128m -Xmx128m -XX:PermSize=128m -XX:MaxPermSize=128m...

$ free -m
             total       used       free     shared    buffers     cached
Mem:           594        341        253          0          7        104
-/+ buffers/cache:        229        365
Swap:            0          0          0

.../usr/lib/jvm/jre/bin/java -Xms328m -Xmx328m -XX:PermSize=128m -XX:MaxPermSize=128m...

$ free -m
             total       used       free     shared    buffers     cached
Mem:           594        426        167          0          7        104
-/+ buffers/cache:        314        279
Swap:            0          0 

What could be the reason?

Charles
  • 50,943
  • 13
  • 104
  • 142
kgautron
  • 7,915
  • 9
  • 39
  • 60

1 Answers1

1

This is because of how I imagine the Linux kernel allocates RAM. It's my possibly flawed understanding that while you can request a big chunk of RAM, it may not be actually accounted for as used until the virtual memory subsystem does something with it (i.e. it's actually been written to).

So, the difference you see is that the threshold for garbage collection runs has shifted, so there's a slight difference in utilization. You'll notice a bigger difference if you start storing larger data sets in RAM.

PaulProgrammer
  • 16,175
  • 4
  • 39
  • 56
  • (+1) Sounds about right. Some terms often used are "reserved" vs. "committed" memory. Also check out this SO link for more details: http://stackoverflow.com/questions/1098488/jvm-heap-parameters – SeKa Mar 24 '13 at 04:51