heroku / heroku-buildpack-jvm-common

Heroku's OpenJDK buildpack. A component of the Java, Scala, and Clojure buildpacks.
MIT License
43 stars 2 forks source link

Support cgroups v1 and v2 for memory limits #305

Closed dzuelke closed 1 month ago

dzuelke commented 4 months ago

For v2, it uses memory.high if available (recommended way of setting a functioning soft limit), then first falls back to memory.max (e.g. from docker run -m), then to memory.low (e.g. from docker run --memory-reservation), and finally to memory.min.

Falls back to direct reading of /sys/fs/cgroup/memory/memory.limit_in_bytes for cases where that exists, but no full cgroupfs is mounted (e.g. on Heroku).

Limit enforcement (now to 8 TB) is still in place this way - a Docker v1 value will be read, and run into the limit for unrestricted containers, without hitting the fallback and getting returned.

GUS-W-16051950

Malax commented 4 months ago

Echoing the sentiment @edmorley had in this comment for the same code in the Python buildpack: https://github.com/heroku/heroku-buildpack-python/pull/1599#pullrequestreview-2132305616