Initial cut at a lazy decommit strategy.

This does not deallocate memory until the OS tells us that we are short
on memory, then tries to decommit all of the cached chunks (except for
the first page, used for the linked lists).

Nowhere near enough testing to commit to master yet!
This commit is contained in:
David Chisnall
2019-02-20 16:34:50 +00:00
committed by David Chisnall
parent 7a9ce97166
commit 66cec23b23
9 changed files with 243 additions and 6 deletions

View File

@@ -60,14 +60,30 @@ namespace snmalloc
enum DecommitStrategy
{
/**
* Never decommit memory.
*/
DecommitNone,
/**
* Decommit superslabs when they are no entirely empty.
*/
DecommitSuper,
DecommitAll
/**
* Decommit all slabs once they are empty.
*/
DecommitAll,
/**
* Decommit superslabs only when we are informed of memory pressure by the
* OS, do not decommit anything in normal operation.
*/
DecommitSuperLazy
};
static constexpr DecommitStrategy decommit_strategy =
#ifdef USE_DECOMMIT_STRATEGY
USE_DECOMMIT_STRATEGY
#elif defined(_WIN32)
DecommitSuperLazy
#else
DecommitSuper
#endif