I have a host machine with 16 GB RAM, on which I have deployed some containers with docker-compose.
I did not set any memory limit for the containers.
One of the containers contains a single java process which executes a task and generates statistics regularly with Quartz. I noticed that this process no longer worked correctly because I no longer had any generated statistics. The process logs show the error
java.lang.OutOfMemoryError: Java heap space.
But despite this the container is still running, it has not been killed and restarted by Docker (and the java process inside the container no longer responds anymore).
I think I understood that the container would have been killed by Docker if the memory usage had reached the memory limit of the container, whereas in my case the error occurred because the process reached the memory limit of the JVM.
Is it possible to kill and restart a process when an OOM error occured on JVM heap space, even if the memory usage has not reached the memory limit of the container ?