Reputation: 338
I set the xmx of jvm equals to 4 G, but after running for a time, when I use top to see the memory, it shows the process used 12 G memory.
So what the xmx actually mean? what should I do if I want to limit the jvm memory to 4 G ?
command line: -server -Xms4g -Xmx4g
And another related question :)
If the gc happens, will the space of the objects that not used any more in young generation be inevitably released by JVM ? or some of them left to the next gc ?
thanks
Upvotes: 2
Views: 2877
Reputation: 51481
The -Xmx option to the JVM specifies the maximum size of the Java
garbage collected heap
. It does NOT limit the size of the memory used by the JVM. The size of the process reported by ps or top will
include that, plus any other memory used by the process. The following
are examples of things that are not part of the garbage collected heap
and yet are part of the memory required by the process:
Upvotes: 7