How JVM -XX:MaxRAM option can be correctly used? [duplicate]

亡梦爱人 提交于 2020-04-16 02:26:14

问题


I run a java application with the following parameters:

#!/bin/bash

export JVM_OPTS="-XX:MaxRAM=150m"
export JVM_OPTS="$JVM_OPTS -XX:+UseSerialGC"

java $JVM_OPTS -jar application.jar

The htop shows:

  • VIRT=475M
  • RES=238M
  • SHR=4880
  • MEM%=24.1

As I understand it, I need to look at the RES parameter. But in this case, it greatly exceeds -XX:MaxRAM. Expected that in this case, OutOfMemoryException will happen. What am I doing wrong? How to limit the memory of a java application for a container? Am I incorrectly looking at the used process memory?

I want to minimize the used RAM. OS - ​​CentOS 7


回答1:


-XX:MaxRAM option affects nothing but the default heap size.

Memory used by a Java process (from the OS perspective) includes not only Java heap, but also many other things. See this answer for details.



来源:https://stackoverflow.com/questions/60636907/how-jvm-xxmaxram-option-can-be-correctly-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!