From 07577620837cd9d550ec15e00694fc10fe957247 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 7 Jun 2021 09:21:22 +0100 Subject: [PATCH] Enable overcommit for heuristic on Linux --- src/pal/pal_linux.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pal/pal_linux.h b/src/pal/pal_linux.h index f9ad8b2..8104b33 100644 --- a/src/pal/pal_linux.h +++ b/src/pal/pal_linux.h @@ -28,6 +28,14 @@ namespace snmalloc static constexpr size_t page_size = Aal::aal_name == PowerPC ? 0x10000 : PALPOSIX::page_size; + /** + * Linux requires an explicit no-reserve flag in `mmap` to guarantee lazy + * commit if /proc/sys/vm/overcommit_memory is set to `heuristic` (0). + * + * https://www.kernel.org/doc/html/latest/vm/overcommit-accounting.html + */ + static constexpr int default_mmap_flags = MAP_NORESERVE; + /** * OS specific function for zeroing memory. *