1

Yesterday I had a problem with a containerized (Docker) Java Spring Boot application. When I'd tried to upload a 5000x5000 pixel image (about 5MB) I had an OOE (out of memory) error during the thumbnail generation.

So I increased the memory limit in this way

resources:
  limits:
    memory: 1024M

but has not been enough to solve. So after a little bit of searches I added this environment variable into the docker-compose.yml

JAVA_TOOL_OPTIONS: '-Xmx1024m'

and now it works.

My question is: JVM doesn't take all the memory allocated for the container specified in resource > memory > limit: 1024M?

Why is necessary to pass the -Xmx parameter in order to increase the heap space?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
HK15
  • 737
  • 1
  • 14
  • 32
  • 2
    For Docker/Kubernetes usages, it is probably better to rely on `-XX:MaxRamPercentage=80` or something like that. And for reference, recent Java versions actually look to the cgroup limits, but by default it's pretty low (something like 25% for cgroup memory limit > 1GB). – Mark Rotteveel Jun 04 '21 at 15:56

0 Answers0