This CL implements the memory reclaiming function releaseFreeMemoryToOS
and its associated classes. Most of this code was originally written by
Aleksey for the Primary64 in sanitizer_common, and I made some changes to
be able to implement 32-bit reclaiming as well. The code has be restructured
a bit to accomodate for freelist of batches instead of the freearray used
in the current sanitizer_common code.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/scudo/standalone/release.h | ||
---|---|---|
20 ↗ | (On Diff #196919) | Do you need default args here? |
37 ↗ | (On Diff #196919) | Initialize everything for consistency? |
59 ↗ | (On Diff #196919) | with MSVC 64bit sizeof(~0UL) < sizeof(uptr) or just |
66 ↗ | (On Diff #196919) | same for 1UL |
159 ↗ | (On Diff #196919) | I think the following way it's more readable and easier to see that UNREACHABLE is not possible if (BlockSize <= PageSize) { if (PageSize % BlockSize == 0) { // Same number of chunks per page, no cross overs. FullPagesBlockCountMax = PageSize / BlockSize; SameBlockCountPerPage = true; } else if (BlockSize % (PageSize % BlockSize) == 0) { // Some chunks are crossing page boundaries, which means that the page // contains one or two partial chunks, but all pages contain the same // number of chunks. FullPagesBlockCountMax = PageSize / BlockSize + 1; SameBlockCountPerPage = true; } else { FullPagesBlockCountMax = PageSize / BlockSize + 2; SameBlockCountPerPage = false; } } else { if (BlockSize % PageSize == 0) { // One chunk covers multiple pages, no cross overs. FullPagesBlockCountMax = 1; SameBlockCountPerPage = true; } else { // One chunk covers multiple pages, Some chunks are crossing page // boundaries. Some pages contain one chunk, some contain two. FullPagesBlockCountMax = 2; SameBlockCountPerPage = false; } } |
Addressing Vitaly's comments.
lib/scudo/standalone/release.h | ||
---|---|---|
20 ↗ | (On Diff #196919) | Leaving the Data one so that it can constructed without. |
59 ↗ | (On Diff #196919) | Done. Sidenote: MSVC support is not in the books for any time soon. |
66 ↗ | (On Diff #196919) | That was one of the modifications I made from the initial code. |