4

the following is my app.yaml file for a GAE flexible Java 8 / Jetty application.

runtime: java
env: flex
manual_scaling:
  instances: 1

runtime_config:  # Optional
  jdk: openjdk8
  server: jetty9

resources:
  cpu: 2
  memory_gb: 4.0

env_variables:
  JAVA_HEAP_OPTS: -Xms3072M -Xmx3072M

health_check:
  enable_health_check: False

handlers:
- url: /.*
  script: this field is required, but ignored

For some reason the JAVA_HEAP_OPTS value is not used when deploying the app. A least I don't think it's used, because when I SSH into the docker container, and run the following command, the memory values are much less.

java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

Can someone please tell me what's going or what I need to do differently?

Thanks

trincot
  • 317,000
  • 35
  • 244
  • 286

1 Answers1

0

The variable is applied only to the Java process that runs as the entrypoint of the docker container.

JAVA_HEAP_OPTS is not a magic environment variable that would be automatically and globally applied to any random execution of Java inside the docker container. It is no wonder why you won't see any effect when you launch your own, separate Java process.

Take a look at the following code and you will understand how it works:

Chanseok Oh
  • 3,920
  • 4
  • 23
  • 63
  • Thanks for your reply. So if I'm deploying a war file, with the above configuration, how do I check to see that the JVM running my web application have the correct memory settings applied? – Wessel Oosthuizen Apr 09 '18 at 14:13
  • I bet `ps aux | grep -- '-Xms3072M'` inside the docker container will show you the Java process. If not, try `ps aux | grep java` and check what you see. – Chanseok Oh Apr 10 '18 at 14:45
  • Ok thanks. I get the processes, but how do I check whether the JVM memory settings are correct? – Wessel Oosthuizen Apr 23 '18 at 20:46
  • If you see `-Xmx3027M` has been correctly passed to the Java process when checked with `ps aux`, you can trust that the argument will be in effect. If you still have trouble checking the actual Java command with all the arguments passed, try `jps -m`. It will conveniently list all the arguments passed to each running Java process correctly. If you still don't trust that the passed arguments will be in effect, there are plenty of ways to investigate memory statistics of a live Java process: https://stackoverflow.com/q/14464770/1701388 or https://stackoverflow.com/q/12797560/1701388 – Chanseok Oh Apr 24 '18 at 21:58