POSIX osDecommitMemory has nasty compatibility problems
rts/posix/OSMem.c currently does the following,
#ifdef MADV_FREE // Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED // just swaps memory out r = madvise(at, size, MADV_FREE); #else r = madvise(at, size, MADV_DONTNEED); #endif if(r < 0) sysErrorBelch("unable to decommit memory");
As it turns out, the Linux kernel as of 4.5 supports
MADV_FREE. This means that binary distributions built in such environments will use
MADV_FREE, even if running on an older kernel that does not support this advice. Ultimately this means that any attempt to decommit will fail.