summaryrefslogtreecommitdiff
path: root/linker/linker_block_allocator.h
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2019-01-23 12:19:41 -0800
committerVic Yang <victoryang@google.com>2019-01-23 12:24:46 -0800
commitfb78a4ac1b93218f59aa44089ae5f4dbfababf0d (patch)
tree976bf1fa16427ea8a3bce0cbc6cb29cd94390449 /linker/linker_block_allocator.h
parent176d2fbcaefe4691b8fd7844f6cec8e7a1a22c76 (diff)
linker: Purge block allocator memory when possible
If all allocated memory from a block allocator is freed, it is a good opportunity to purge all the pages allocated to reduce lingering dirty pages. Memory saving varies with the platform and what processes are running. Measuring right after boot, this saves ~1.8MB on cuttelfish and ~1.3MB on a 32-bit ARM device. Bug: 112073665 Test: Boot and check memory usage with 'showmap'. Change-Id: I53769e0ec9699f0b3645cdf281a2c0bbffb98676
Diffstat (limited to 'linker/linker_block_allocator.h')
-rw-r--r--linker/linker_block_allocator.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/linker/linker_block_allocator.h b/linker/linker_block_allocator.h
index bd44fc829..85e6bd962 100644
--- a/linker/linker_block_allocator.h
+++ b/linker/linker_block_allocator.h
@@ -53,10 +53,12 @@ class LinkerBlockAllocator {
private:
void create_new_page();
LinkerBlockAllocatorPage* find_page(void* block);
+ void free_all_pages();
size_t block_size_;
LinkerBlockAllocatorPage* page_list_;
void* free_block_list_;
+ size_t allocated_;
DISALLOW_COPY_AND_ASSIGN(LinkerBlockAllocator);
};
@@ -73,7 +75,8 @@ class LinkerBlockAllocator {
* with size 513 this allocator will use 516 (520 for lp64) bytes of data
* where generalized implementation is going to use 1024 sized blocks.
*
- * 2. This allocator does not munmap allocated memory, where LinkerMemoryAllocator does.
+ * 2. Unless all allocated memory is freed, this allocator does not munmap
+ * allocated memory, where LinkerMemoryAllocator does.
*
* 3. This allocator provides mprotect services to the user, where LinkerMemoryAllocator
* always treats it's memory as READ|WRITE.