mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-12 14:18:42 +03:00
clarify needs_recommit
This commit is contained in:
parent
5c39fe7246
commit
1d231be758
5 changed files with 22 additions and 22 deletions
|
@ -352,16 +352,16 @@ int _mi_prim_commit(void* start, size_t size) {
|
|||
return err;
|
||||
}
|
||||
|
||||
int _mi_prim_decommit(void* start, size_t size, bool* decommitted) {
|
||||
int _mi_prim_decommit(void* start, size_t size, bool* needs_recommit) {
|
||||
int err = 0;
|
||||
#if defined(MADV_DONTNEED) && !MI_DEBUG && !MI_SECURE
|
||||
// decommit: use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE)
|
||||
// (on the other hand, MADV_FREE would be good enough.. it is just not reflected in the stats :-( )
|
||||
*decommitted = false;
|
||||
*needs_recommit = false;
|
||||
err = unix_madvise(start, size, MADV_DONTNEED);
|
||||
#else
|
||||
// decommit: just disable access (also used in debug and secure mode to trap on illegal access)
|
||||
*decommitted = true; // needs recommit to reuse the memory
|
||||
*needs_recommit = true; // needs recommit to reuse the memory
|
||||
err = mprotect(start, size, PROT_NONE);
|
||||
if (err != 0) { err = errno; }
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue