I am learning the code in
Ray. It uses
dlmalloc as the default memory allocator and uses memory-mapping. There is a comment in the file
/// Gap between two consecutive mmap regions allocated by fake_mmap. /// This ensures that the segments of memory returned by /// fake_mmap are never contiguous and dlmalloc does not coalesce it /// (in the client we cannot guarantee that these mmaps are contiguous). constexpr int64_t kMmapRegionsGap = sizeof(size_t);
I wonder why memory allocations are intentionally discontinuous to prevent dlmalloc to coalesce them?