mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-08-24 08:14:48 +03:00
add initial support for _mi_prim_reuse and MADV_FREE_REUSABLE on macOS (issue #1097)
This commit is contained in:
parent
2d34956bed
commit
d389819cc9
8 changed files with 64 additions and 7 deletions
11
src/os.c
11
src/os.c
|
@ -512,6 +512,17 @@ bool _mi_os_reset(void* addr, size_t size) {
|
|||
}
|
||||
|
||||
|
||||
void _mi_os_reuse( void* addr, size_t size ) {
|
||||
// page align conservatively within the range
|
||||
size_t csize = 0;
|
||||
void* const start = mi_os_page_align_area_conservative(addr, size, &csize);
|
||||
if (csize == 0) return;
|
||||
const int err = _mi_prim_reuse(start, csize);
|
||||
if (err != 0) {
|
||||
_mi_warning_message("cannot reuse OS memory (error: %d (0x%x), address: %p, size: 0x%zx bytes)\n", err, err, start, csize);
|
||||
}
|
||||
}
|
||||
|
||||
// either resets or decommits memory, returns true if the memory needs
|
||||
// to be recommitted if it is to be re-used later on.
|
||||
bool _mi_os_purge_ex(void* p, size_t size, bool allow_reset, size_t stat_size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue