简体   繁体   中英

Why is the JVM using more memory than I am allocating

I am starting the Java process with the following command:

java -Xmx32m -jar winstone-lite.jar --warfile=myWarFile.war

Instead of using the amount of memory I specified, it is still allocating 144m.

EDIT: When I say allocate, I mean when I look at the "top" process I am seeing 144m as the amount of memory being used.

I am using http://www.oracle.com/technetwork/java/embedded/documentation/index.html current version.

I would figure that if my application required more memory than I am allocating the jvm would crash.

-Xmx just tells the JVM how much memory it may use for its internal heap.

The JVM needs memory for other purposes (permanent generation, temporary space etc.), plus like every binary it needs space for its own binary code, plus any libraries/DLLs/.so it loads.

The 144 MiB you quote probably contains at least some of these other memory uses.

How did you measure the memory usage? On modern OS using virtual memory, measuring memory usage of a process is not quite trivial, and cannot be expressed as a single value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM