Merge pull request #5729 from martin-g/5616-max-memory-in-container

Take into account the allowed max memory of the container
This commit is contained in:
Clément Renault
2025-08-21 14:43:32 +00:00
committed by GitHub

View File

@ -886,7 +886,10 @@ fn total_memory_bytes() -> Option<u64> {
let mem_kind = RefreshKind::nothing().with_memory(MemoryRefreshKind::nothing().with_ram());
let mut system = System::new_with_specifics(mem_kind);
system.refresh_memory();
Some(system.total_memory())
system
.cgroup_limits()
.map(|limits| limits.total_memory)
.or_else(|| Some(system.total_memory()))
} else {
None
}