java命令启动参数-Xms -Xmx的问题
阿神
阿神 2017-04-17 13:03:48
0
3
401

启动命令如下:

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

top命令显示如下:

  PID   USER    PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  15332 root    17   0  555m 242m  11m S  0.0 12.1   1:46.95 java

疑问:

为什么VIRT和RES大于128m呢?难道-Xms -Xmx没起作用?

阿神
阿神

闭关修行中......

reply all(3)
Peter_Zhu

These two parameters are just the limit value Java程序的heap size. If you understand heap and stack then you should know that generally only 运行时动态创建的对象 exists in heap

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

In addition, the resource status viewed through the top command is for the entire Java process. When the JVM executes your Java code, it also needs to load the entire Java Runtime, which has its own overhead. These are not included in -Xms/-Xmx

From Oracle'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.

伊谢尔伦

The memory occupied by top also includes PermSize, etc., which is the total of the entire process. Okay, let me ask a novice question

左手右手慢动作

Because you just set the maximum value of java heap memory. In addition to the heap, the jvm also has a stack, method area, and constant pool.

In fact, even if the maximum value of each memory area is set, the final memory usage may still be exceeded. Because memory management also requires memory

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!