Repository navigation
[stable35] fix(linux): report container memory limits instead of the host's - #1121
Merged
Merged
Conversation
/proc/meminfo is not namespaced, so inside Docker, Kubernetes or AIO the Monitoring page and the OCS API reported the host's RAM rather than the memory Nextcloud is actually allowed to use. On a 2 GiB container running on a 64 GiB host, that is off by a factor of 32. Where a cgroup memory limit applies, read the limit and usage from it instead, preferring the v2 unified hierarchy and falling back to v1. Reclaimable page cache is discounted from the usage so that MemAvailable keeps the meaning it has in /proc/meminfo, and swap is taken from memory.swap.* on v2 and derived from the memsw counters on v1. A cgroup that is not more restrictive than the host is ignored, which covers both "max" on v2 and the near-PHP_INT_MAX sentinel on v1, so hosts without a limit keep reporting exactly what they reported before. Signed-off-by: Frank Karlitschek <frank.karlitschek@nextcloud.com> Assisted-by: Claude Code:claude-opus-5 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
backportbot
Bot
requested review from
benjaminfrueh and
kesselb
as code owners
September 9, 2026 15:09
Member
kesselb
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #1118