0
votes

I'm getting this when I try to push my Tomcat project to IBM Cloud:

Cannot calculate JVM memory configuration: There is insufficient memory remaining for heap. Memory available for allocation 256M is less than allocated memory 578931K(-XX:ReservedCodeCacheSize=240M,-XX:MaxDirectMemorySize=10M, XX:MaxMetaspaceSize=66931K, Xss1M * 250 threads)

I cannot increase the memory limit. I tried using JVM flags to reduce the JVM’s memory usage in manifest.yml file:

env:
    JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss160k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M'

and tried to use an older version of java buildpack, also in manifest.yml file:

buildpack: https://github.com/cloudfoundry/java-buildpack#v3.19.2 

but I got errors doing both things. What can I do to solve this?

2
Depending on how your program is structured, you should most likely try to decrease the memory footprint. Maybe you're declaring a very large array, or another large object.Pika Chu
How much memory does it take to run locally?nitind
Something is wrong with the way you are adding the JAVA_OPTS since you set -XX:ReservedCodeCacheSize=16M and the error still reports -XX:ReservedCodeCacheSize=240M. Find a way to reliably set JAVA_OPTScmoetzing
Cloud be a cut and paste error, but your spacing looks off on the env block. Try throwing your manifest.yml into a YAML validator to make sure it's formatted properly.@cmoetzing it's not picking up your changes. Also, don't switch back to using JBP v3. You should absolutely be using the latest v4.x.Daniel Mikusa

2 Answers

0
votes

You can try to reduce your Tomcat max thread pool to the minimum as the default is 200. Of course it would really reduce its concurrency and limit the access to the web server to a very limited number of users.

Unfortunately the Java footprint for a web server is quite high and with the recent CF buildpacks I was not able to startup a server with less than 1GB of memory (well, I was, but not for production purposes).

0
votes

Facing the same issue?

env: -JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss160k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M' -JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {stack_threads: 10, memory_sizes: {stack: 512k}}]'

used this in manifest.yml file