Sign inSign up

demaniak/java-buildpack-memory-calculator

By demaniak

Updated over 8 years ago
Archived

The Java buildpack memory calculator determines values for JVM memory options.

Image
0

515

demaniak/java-buildpack-memory-calculator repository overview

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.

Please see

Usage

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

Can be easier

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

A note about output

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.

Tag summary

Content type

Image

Digest

Size

126 MB

Last updated

over 8 years ago

docker pull demaniak/java-buildpack-memory-calculator