|
|
|
|
|
by praseodym
3158 days ago
|
|
Actually the `-XX:+UseCGroupMemoryLimitForHeap` option is also in Java 8 since Java 8u131, so it's available for nearly everyone right now. It doesn't solve a lot of problems though: by default the JVM will use only 1/4th of the memory (cgroup) limit as its heap size, which wastes most of the container's memory. It's thus attractive to use `-XX:+UseCGroupMemoryLimitForHeap` together with `-XX:MaxRAMFraction=1` to get maximum heap size given your container limits. However, because total JVM memory is heap+permgen+threads*stacksize, you'll leave no memory for threads this way. If you're running an average web server, it will spawn dozens of threads and get your application above the cgroup memory limit (=OOM killed) pretty fast. The only way out is to configure memory limits by hand, taking into account the maximum number of threads your application will use. That usually isn't trivial. |
|