mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-01 09:14:38 +03:00
Made a mistake. Fixed for non-apple unix
This commit is contained in:
parent
157b201004
commit
e784983b76
1 changed files with 26 additions and 27 deletions
|
@ -440,18 +440,18 @@ int _mi_prim_commit(void* start, size_t size, bool* is_zero) {
|
|||
}
|
||||
|
||||
int _mi_prim_decommit(void* start, size_t size, bool* needs_recommit) {
|
||||
int err = 0;
|
||||
#if defined(__APPLE__)
|
||||
// On Apple platforms there is MADV_FREE_REUSABLE -- it marks memory as RESUABLE to reduce memory pressure.
|
||||
err = unix_madvise(start, size, MADV_FREE_REUSABLE);
|
||||
// if this fails - fallback to MADV_DONTNEED
|
||||
#endif
|
||||
|
||||
if (err)
|
||||
int err = unix_madvise(start, size, MADV_FREE_REUSABLE);
|
||||
if (err != 0) // if MADV_FREE_REUSABLE fails - fallback to MADV_DONTNEED
|
||||
{
|
||||
// use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE)
|
||||
err = unix_madvise(start, size, MADV_DONTNEED);
|
||||
}
|
||||
#else
|
||||
// use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE)
|
||||
int err = unix_madvise(start, size, MADV_DONTNEED);
|
||||
#endif
|
||||
|
||||
#if !MI_DEBUG && MI_SECURE<=2
|
||||
*needs_recommit = false;
|
||||
|
@ -474,11 +474,11 @@ int _mi_prim_reset(void* start, size_t size) {
|
|||
#if defined(__APPLE__)
|
||||
// On Apple platforms there is MADV_FREE_REUSABLE -- it marks memory as RESUABLE to reduce memory pressure.
|
||||
err = unix_madvise(start, size, MADV_FREE_REUSABLE);
|
||||
if (err == 0)
|
||||
return 0;
|
||||
// if this fails - fallback to MADV_FREE/MADV_DONTNEED
|
||||
#endif
|
||||
|
||||
if (err)
|
||||
{
|
||||
// We try to use `MADV_FREE` as that is the fastest. A drawback though is that it
|
||||
// will not reduce the `rss` stats in tools like `top` even though the memory is available
|
||||
// to other processes. With the default `MIMALLOC_PURGE_DECOMMITS=1` we ensure that by
|
||||
|
@ -495,7 +495,6 @@ int _mi_prim_reset(void* start, size_t size) {
|
|||
#else
|
||||
err = unix_madvise(start, size, MADV_DONTNEED);
|
||||
#endif
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue