mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +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
|
||||
|
|
|
@ -131,9 +131,9 @@ int _mi_prim_commit(void* addr, size_t size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int _mi_prim_decommit(void* addr, size_t size, bool* decommitted) {
|
||||
int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit) {
|
||||
MI_UNUSED(addr); MI_UNUSED(size);
|
||||
*decommitted = false;
|
||||
*needs_recommit = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -262,9 +262,9 @@ int _mi_prim_commit(void* addr, size_t size) {
|
|||
return (p == addr ? 0 : (int)GetLastError());
|
||||
}
|
||||
|
||||
int _mi_prim_decommit(void* addr, size_t size, bool* decommitted) {
|
||||
int _mi_prim_decommit(void* addr, size_t size, bool* needs_recommit) {
|
||||
BOOL ok = VirtualFree(addr, size, MEM_DECOMMIT);
|
||||
*decommitted = true; // for safetly, assume always decommitted even in the case of an error.
|
||||
*needs_recommit = true; // for safetly, assume always decommitted even in the case of an error.
|
||||
return (ok ? 0 : (int)GetLastError());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue