Java command startup parameter -Xms -Xmx problem

  java, question

The startup command is as follows:

java -server -Xms128m -Xmx128m -jar xxxx.jar

The top command displays the following:

Pidouerprini virtres s% Central Processor% MEM TIME+COMMAND
 15332 root    17   0  555m 242m  11m S  0.0 12.1   1:46.95 java


Why are VIRT and RES larger than 128m? Did -Xms -Xmx not work?

These two parameters are only limit valuesHeap of Java programSize, if you understandheapAndStackThen it should be known that generally onlyObjects dynamically created at runtimeOnly exists inheapIn

$ java -X
 -Xms<size>        set initial Java `heap size`
 -Xmx<size>        set maximum Java `heap size`

In addition, throughTopThe resources viewed by the command are for the entire Java process, and the JVM needs to load the entire Java code when executing it.Java Runtime, have their own expenses, these are not included in-Xms/-XmxIn

FromOracle’s Documentation:

Note that the JVM uses more memory than just the heap. For example
Java methods, thread stacks and native handles are allocated in memory
separate from the heap, as well as JVM internal data structures.