Configuring Memory in Docker Containers
You can configure SAP Commerce memory settings to prevent Docker containers from exceeding memory limits and getting killed as a result.
If you assign a resource limit to a container, the operating system restricts container access to the CPU and/or memory. If a process running inside the container exceeds the memory limit, the container gets killed. You should avoid such situations by properly configuring SAP Commerce memory settings.
You can use the $CATALINA_MEMORY_OPTS and $ADDITIONAL_CATALINA_OPTS environment variables to configure the memory options in a SAP Commerce image. SAP Commerce sets the maximum and minimum heap size to 2GB by default. Your configuration, however, should always meet the requirements of your environment.
If you don't specify the -Xms -Xmx settings explicitly, JVM tries to set these values automatically using the process called ergonomics. For example, the XX:MaxRAMFraction property specifies how much of available memory should be assigned for the heap space. We recommend setting memory explicitly instead of relying on automatic configuration. There are many more memory areas used by JVM besides heap, such as Class, Thread, Code, GC, Compiler, Internal and symbol memory areas. For that reason it is problematic to calculate how much memory is enough for your application. When relying on MaxRAMFraction (although it is not recommended), make sure that JVM uses the container memory limit instead of the system host. You can enable it by the -XX:+UnlockExperimentalVMOptions and -XX:+UseCGroupMemoryLimitForHeap properties.