What is the usual recommended heap memory setting for a production environment, 1 microservice written in Java, if compiled as a native image using GraalVM Community Edition? Should I specify both -xms and -xms to keep the minimum heap and maximum heap size the same?
1 Answers
There is no recommendation from documentation, it says
Java Heap Size When executing a native image, suitable Java heap settings will be determined automatically based on the system configuration and the used GC. To override this automatic mechanism and to explicitly set the heap size at run time, the following command-line options can be used:
-Xmx - maximum heap size in bytes
-Xms - minimum heap size in bytes
-Xmn - the size of the young generation in bytes
See here for full document. JVM memory management is an old topic discussed many times before
how to choose the jvm heap size?
java - best way to determine -Xmx and -Xms required for any webapp & standalone app
long story short for any application there is no "one" number. Some application may require 4GB some require 64GB depends to the "load" and data used per request(webapp) or OS(win/linux) app runs on. After you monitor the app sometime you can decide. It is not easy so that's why people are going serverless lately.

- 3,199
- 31
- 48
-
Hello, can I ask you a question, if I deploy 1 Java application with serverless technology, I don't need to go to pre-set heap size? And how is its heap size managed? – 李志博 Feb 19 '23 at 02:27
-
yes in theory, main idea is to not to configure heap size, it automatically calculate needs and increase and decrease, this may change provider to provider you can check AWS Google and Azure serverless options. – ozkanpakdil Feb 19 '23 at 14:05