Proper memory settings for Java

I am doing a matrix using curl from the command line to my local host ors-app. The matrix is ~1,100 X 1,100 in size. I’m using the entire continental US pbf, which comes in at about 9.41 GB for the graphs. I have disabled elevations as I’m not too concerned with the heights. When the command is executed, it runs for a couple of minutes then returns a “java.lang.OutOfMemoryError: Java heap space” error.

Being a noob with Java heap spaces and Docker, I foolishly increased the amount of RAM my docker uses from 14GB to 20GB, but the error continued.

I’ve been able to find exactly what is happening, based on these web pages,



This paragraph says it all.

So what’s wrong with JVM? The JVM is not fully aware of the isolation mechanism used in containers . Containers are not like VMs, they are basically isolated linux process groups. Java application running in docker container always sees the full resources of the host. That means when you run a dockerized Java application in a VM having 128GB RAM, your java application thinks that 125GB RAM belongs to it.

So my question is, how do I overcome this? I’ve set the docker-compose.yml file Java settings to this

  - "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms7g -Xmx14g"

As I had to do this to even get the container to build. I’ve verified that the container runs with fewer input locations to the matrices, however there is no joy when I need to run the full matrix.

At this point I’m pretty much at a loss on how to proceed. Ideas?



The first thing to realise is that if you are doing a 1,000 x 1,000 matrix, then it needs do to 1,000,000 routes for that, and the data from these need to be stored in memory whilst it computes the matrix values. One of the main reasons we have a lower limit on our api for matrix requests (in effect 50x50) is because of this resource need in terms of both RAM and time.

I can’t really give any information about JVM and Docker as that is outside of my expertise

Thanks, I had already figured that out. If each route requires 1 kb, then it would need ~1GB for all the routes. I’ve already bumped it up to 20GB, but that didn’t help.

Any idea who to check with regarding JVM and Docker?