We been getting `java.lang.OutOfMemoryError: Java ...
# all-things-deployment
h
We been getting
java.lang.OutOfMemoryError: Java heap space
when loading a particularly large entity (large schema, with descriptions and tags), and we realized we haven't touched the
JAVA_OPTS
. As a complete Java beginner, are there any rule of thumb or recommendations for setting the heap size?
s
Copy code
extraEnvs:
- name: JAVA_OPTS
  value: "-Xms1g -Xmx1g"
resources:
  limits:
    cpu: 500m
    memory: 1280Mi
   requests:
     cpu: 300m
     memory: 1280Mi
^ above is for kubernetes helm chart
1g
is
1 GB
If you are doing many big entities
2 GB
is something you can start with i.e.
2g
in the
JAVA_OPTS
These will go in GMS
So should be this
Copy code
-Xms2g -Xmx2g
If using Kubernetes the resource request and limit will need to be increased correspondingly
h
Nice thanks! I assume it's not a good idea to set the
-Xmx
to the same as the k8s resource request, a small buffer is probably good. What would be a good ratio? 75% or more?'
s
It is not a %age thing more of some basic overhead for other processes. I kept 256Mi extra over 1 GB (1024Mi). You can add similar overhead to 2 GB
h
Okey, got it! Thanks!