mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-08 05:04:17 +03:00
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:
parent
21a68e2d22
commit
7cbcd2e2b7
4 changed files with 21 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue