The Java buildpack memory calculator determines values for JVM memory options.
515
DISCLAIMER I have no affiliation with the "java-buildpack-memory-calculator" project or authors, nor do I have any involvement with the source code of that project.
You use the output of this image at your own risk.
Example run (NOTE: this is JUST an example, you will need to adjust parameters for your application!):
docker run --rm --entrypoint=/go/bin/java-buildpack-memory-calculator demaniak/java-buildpack-memory-calculator \
-loadedClasses 17200 \
-poolType metaspace \
-stackThreads 35 \
-totMemory 400M
Example output from above:
-Xmx6666K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=111093K
For java 8 and 9 (perhaps 10 also?) I would suggest you add the following options also (also mentioned in the links above):
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
-XX:MaxRAMFraction=1
So that works, but if we trust in the "rule-of-thumb guestimates" as explained in the links above, we can make things easier:
docker run --rm demaniak/java-buildpack-memory-calculator 50 512M
Which will produce something like:
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -Xmx95254K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=126953K
If the calculator is not happy, the exit code will be non-zero. BUT, there will still be output:
Cannot calculate JVM memory configuration: There is insufficient memory remaining for heap. Memory available for allocation 256M is less than allocated memory 429033K (-XX:ReservedCodeCacheSize=240M, -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=126953K, -Xss1M * 45 threads)
The exit code of a successful calculation will be zero.
Content type
Image
Digest
Size
126 MB
Last updated
over 8 years ago
docker pull demaniak/java-buildpack-memory-calculator