kgautron
kgautron

Reputation: 8283

Xms option impact on memory usage

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?

Upvotes: 0

Views: 1697

Answers (1)

PaulProgrammer
PaulProgrammer

Reputation: 17690

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.

Upvotes: 1

Related Questions