I want to make changes in memory settings for my java apps in cloudfoundry java-buildpack. I have tried these two ways:
memory_calculator:
version: 3.8.0_RELEASE
repository_root: "{default.repository.root}/memory-calculator/{platform}/{architecture}" stack_threads: 300
memory_sizes:
stack: 2M
metaspace: 160M
heap: 900M
However, none of this is getting reflected while deployment of my apps. I am using latest java-buildpack.
This depends on the version of the Java build pack that you're using.
For versions 3.x, you would set an env variable to configure the memory calculator. Like here.
https://github.com/cloudfoundry/java-buildpack/tree/3.x#configuration-and-extension
Ex:
cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ memory_calculator: { memory_heuristics: { heap: 85, stack: 10 } } }'
This will then override the memory heuristics configuration that defaults in the build pack, specifically the heap and stack weights.
A few notes:
JBP_CONFIG_ORACLE_JRE
for Oracle. The name mirrors the config file path & name.cf set-env
like above or you can set the env variable in your manifest.yml file. Both work just fine.In version 4.x, the configuration of the JVM's memory settings has gotten a lot simpler.
however if you believe that your application doesn’t need these JVM defaults, you can now configure those memory regions directly with JVM options.
https://www.cloudfoundry.org/just-released-java-buildpack-4-0/
What this means is you still configure the JVM settings through an env variable, but you only need to set JAVA_OPTS
and you use the standard JVM configuration options.
For example:
cf set-env my-app JAVA_OPTS '-XX:ReservedCodeCacheSize=100M'
You can set JAVA_OPTS
in your manifest.yml, if you prefer doing that instead of running cf set-env
.
Hope that helps!