java-buildpack-memory-calculator calculates effective JVM memory configurations to optimize application performance within container limits. The tool takes input such as total memory, loaded class count, and thread count. It then determines JVM options like heap size, direct memory, and metaspace, aiming for a balanced allocation that prioritizes non-heap memory when limits are constrained.
The calculator provides a structured approach to JVM memory tuning, automating the calculation of key parameters. It considers various JVM options, offering flexibility with user-defined overrides. The design prioritizes non-heap memory allocation to mitigate heap space reduction when total memory is limited. The implementation directly utilizes engine defaults for parameters not configured by the user.
- Heap Size Calculation: Calculates heap size based on total memory, headroom, and other JVM parameters.
- Direct Memory Configuration: Configures
-XX:MaxDirectMemorySizebased on user input or a default value. - Metaspace Configuration: Calculates
-XX:MaxMetaspaceSizebased on the number of loaded classes. - Code Cache Configuration: Configures
-XX:ReservedCodeCacheSizebased on user input or the JVM default. - Thread Stack Size: Configures
-Xssbased on user input or the JVM default. - JVM Options Override: Allows users to override calculated values through standard JVM options.
- Apache 2.0 License: Released under the Apache 2.0 license for open-source use.
The project appears stable with recent commits and a reasonable number of stars and forks, indicating ongoing maintenance and community interest. The documentation provides clear usage instructions and explanations of the calculation algorithm, enhancing usability for developers. The project has been available since 2015, showing sustained interest.
Developers deploying Java applications on Cloud Foundry can leverage this tool to automate JVM memory configuration. It helps ensure applications meet performance requirements while staying within container memory limits, preventing resource exhaustion and ensuring stable deployments. It eliminates guesswork and provides a starting point for informed memory tuning, adapting to varying application needs.
