When setting the memory limit for a container in a swarm environment, it's recommended to allocate some additional memory on top of the container's actual requirement to account for the overhead introduced by the Docker daemon, networking, and other system processes.
As a general guideline, you can allocate an additional 10-20% of memory on top of the container's actual requirement. In the case where JAVA_MAX_MEM is set to 16GB, you could consider setting the container memory limit to around 18-20GB to provide some extra headroom.
When setting the memory limit for a container in a swarm environment, it's recommended to allocate some additional memory on top of the container's actual requirement to account for the overhead introduced by the Docker daemon, networking, and other system processes.
As a general guideline, you can allocate an additional 10-20% of memory on top of the container's actual requirement. In the case where JAVA_MAX_MEM is set to 16GB, you could consider setting the container memory limit to around 18-20GB to provide some extra headroom.