ghc runtime by default (otherwise depending on a "configure" option) does memory allocation on their own by first mmapping a 1 TB range of memory into the process and then parceling out chunks from it. If one of the chunks is not needed, the kernel needs to be informed - otherwise the system would quickly run out of available RAM. ghc does that via madvise(2). There are two options when doing this informing: MADV_FREE - Means "I don't need this range or the data in it any more". Kernel promises to fail later accesses to it. MADV_DONTNEED - Means "I don't need this range right now - and I don't need the data in it anymore". Kernel promises to make later accesses to it succeed (if necessary by providing a new page initialized with zeroes). MADV_FREE was introduced in Linux 4.5. glibc 2.25 and later always define MADV_FREE. Unpatched ghc 8.0.2 will use either MADV_FREE or MADV_DONTNEED, determined at ghc compile time. Which of them will actually succeed is determined by the Linux kernel at run time. This patch makes ghc try MADV_FREE. If it doesn't work, it falls back to MADV_DONTNEED. The end result is that ghc programs free their memory with Linux <
aboutsummaryrefslogtreecommitdiff
path: