We are running a java8/jetty9 setup on appengine flex. In the app.yaml we have allocated 30G of RAM. However in the server, when we call Runtime.getRuntime().maxMemory()
, the number returned is ~7G. If I increase the RAM to 60G, this number increases to ~15G. Seems like the JVM only gets a quarter of the RAM we have allocated in app.yaml.
I also tried running the server with -Xmx30g
However the server upload failed with the error
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (mmap) failed to map 7158235136 bytes for committing reserved memory.
The error confirming what we were seeing with Runtime.getRuntime().maxMemory
, that there is a limit of ~7G when we have allocated 30G of RAM.
Where is the rest of the 75% allocation going?
Here is the Dockerfile
FROM gcr.io/google-appengine/jetty9 RUN apt-get -q update && \ apt-get -y -q --no-install-recommends -t jessie-backports install openjdk-8-jdk && \ apt-get -y -q --no-install-recommends install ssh sshpass && \ apt-get clean && \ rm /var/lib/apt/lists/*_* ADD backend.war $JETTY_BASE/webapps/root.war WORKDIR $JETTY_BASE RUN java -jar -Xmx30g -Xms20g $JETTY_HOME/start.jar --approve-all-licenses \ --add-to-startd=jmx,stats,hawtio,requestlog \ -Djava.util.logging.config.file=src/main/appengine/logging.properties \ && chown -R jetty:jetty $JETTY_BASE
Here is the app.yaml
runtime: custom threadsafe: true env: flex handlers: - url: /.* script: this field is required, but ignored secure: always health_check: enable_health_check: True check_interval_sec: 5 timeout_sec: 4 unhealthy_threshold: 2 healthy_threshold: 2 resources: cpu: 6 memory_gb: 30 disk_size_gb: 20 automatic_scaling: min_num_instances: 1 max_num_instances: 3 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.5