Search code examples
graalvm

How to set the heap size for GraalVM native image?


How can I control the heap size of a native image created with GraalVM native-image?

Does the native image evaluate the usual JVM -Xmx argument?


Solution

  • You can specify the heap size with -Xmx{n} command line parameter. For instance,

    ./your-native-binary -Xmx16m
    

    will set 16m heap size for Substrate VM. You can also add -XX:+PrintGC flag to check garbage collector activity:

    ./your-native-binary -XX:+PrintGC -XX:+PrintGCTimeStamps -Xmx16m