mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02: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:
parent
aa366d593d
commit
45da2257ec
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue