I am using Java 11 on CentOS 7.x, because the server only have 2GB momory, Now I want to limit the max memory usage. I have tried this way:
nohup ${JAVA_HOME}/bin/java -Xmx256M -Xms128M -jar \
-Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=0.0.0.0:5019 \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/apps/dolphin-post/ \
${APP_HOME}/${APP_NAME} >> ./cruise.log &
but the memory usage seems greater than 256MB(360MB+). This is the running status of the app(top -bcn1 -w512
):
6059 root 20 0 2600460 364792 15280 S 0.0 19.4 0:51.38 /usr/local/jdk/bin/java -Xmx256M -Xms128M -jar -Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=0.0.0.0:5019 /opt/apps/dolphin-post/libs/dolphin-post-service-1.0.0-SNAPSHOT.jar
is there any way to limit the java memory usage?