Yasmin Pierazo
Yasmin Pierazo

Reputation: 11

JVM insufficient memory issue

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?

Upvotes: 0

Views: 2244

Answers (2)

Abhishek Vaidya
Abhishek Vaidya

Reputation: 1

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

Upvotes: 0

Squake
Squake

Reputation: 427

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).

Upvotes: 0

Related Questions