How much memory does JVM use (at maximum)?

The java -Xmx option can be used to set the maximum amount of memory the Java application can use. But in the Windows Task Manager, the "java.exe" process can use more than this upper limit (e.g. started app with -Xmx128m to use up to 128 MB but Task Manager shows for the java.exe process 219 MB!). Is there any information (documentation, rule) to calculate the real maximum amount of system memory a Java application can use at maximum?

E.g. if the Java application is allowed to take a maximum of 1 GB of memory, I have to chose a -Xmx parameter value of less than 1 GB ... but how much less?

[609 byte] By [MartinHilperta] at [2007-11-27 11:39:16]
# 1

The -Xmx option just sets the maximum java application heap size.

There are a bunch of other memory areas allocated by the JVM.

tschodta at 2007-7-29 17:25:08 > top of Java-index,Desktop,Runtime Environment...
# 2

Yes, I know about the Xmx. But is there some rule about the additional memory the JVM uses? So far, I read that you can't control the total memory usage of the JVM. It would be helpful to have at least some hints about the additional/total memory consumption.

MartinHilperta at 2007-7-29 17:25:08 > top of Java-index,Desktop,Runtime Environment...
# 3

> is there some rule

> about the additional memory the JVM uses?

Many.

The JVM is a native application - its memory requirements in that respect are not atypical.

Then there is the well known Java heap.

And then there is JVM thread stack space for the java threads.

And then there are a couple additional heap like areas - perm space and direct memory.

Then you have to consider JNI - dunno much about that.

Possibly a few I have forgotten.

The best thing you can do is go away and read a lot about all this.

tschodta at 2007-7-29 17:25:08 > top of Java-index,Desktop,Runtime Environment...
# 4

Out of curiosity - are you wanting to control the size of all native programs, or just the jvm?

ChuckBinga at 2007-7-29 17:25:08 > top of Java-index,Desktop,Runtime Environment...