Fix pages_purge_forced() to discard pages on non-Linux systems.
madvise(..., MADV_DONTNEED) only causes demand-zeroing on Linux, so fall back to overlaying a new mapping.
This commit is contained in:
@@ -170,6 +170,9 @@ pages_purge_lazy(void *addr, size_t size) {
|
||||
VirtualAlloc(addr, size, MEM_RESET, PAGE_READWRITE);
|
||||
#elif defined(JEMALLOC_PURGE_MADVISE_FREE)
|
||||
madvise(addr, size, MADV_FREE);
|
||||
#elif defined(JEMALLOC_PURGE_MADVISE_DONTNEED) && \
|
||||
!defined(JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS)
|
||||
madvise(addr, size, MADV_DONTNEED);
|
||||
#else
|
||||
not_reached();
|
||||
#endif
|
||||
@@ -182,8 +185,12 @@ pages_purge_forced(void *addr, size_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(JEMALLOC_PURGE_MADVISE_DONTNEED)
|
||||
#if defined(JEMALLOC_PURGE_MADVISE_DONTNEED) && \
|
||||
defined(JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS)
|
||||
return (madvise(addr, size, MADV_DONTNEED) != 0);
|
||||
#elif defined(JEMALLOC_MAPS_COALESCE)
|
||||
/* Try to overlay a new demand-zeroed mapping. */
|
||||
return pages_commit(addr, size);
|
||||
#else
|
||||
not_reached();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user