mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-05 20:26:31 +00:00
Take into account the allowed max memory of the container
When Meilisearch runs inside a container (e.g. Docker or Kubernetes) it may run with less max memory than the available on the host, e.g. `docker run --memory 1G ...` Fixes #5616 Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
@ -865,7 +865,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
|
||||
}
|
||||
|
Reference in New Issue
Block a user