summaryrefslogtreecommitdiff
path: root/linker/linker_block_allocator.h
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2019-01-29 20:23:16 -0800
committerVic Yang <victoryang@google.com>2019-01-30 22:13:13 -0800
commitbb7e1236f3676baffd5953061154e9a3552317d7 (patch)
treea1ddb820db657e34a56e66dd81a0b04a46922673 /linker/linker_block_allocator.h
parent58dd1cbd7f2a0b8a779f2f43c45447cdccc09c3e (diff)
Purge linker block allocators before leaving linker
This is the second attempt to purge linker block allocators. Unlike the previously reverted change which purge allocators whenever all objects are freed, we only purge right before control leaves the linker. This limits the performance impact to one munmap() call per dlopen(), in most cases. Bug: 112073665 Test: Boot and check memory usage with 'showmap'. Test: Run camear cold start performance test. Change-Id: I02c7c44935f768e065fbe7ff0389a84bd44713f0
Diffstat (limited to 'linker/linker_block_allocator.h')
-rw-r--r--linker/linker_block_allocator.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/linker/linker_block_allocator.h b/linker/linker_block_allocator.h
index 0c54b93fa..8ae4094be 100644
--- a/linker/linker_block_allocator.h
+++ b/linker/linker_block_allocator.h
@@ -50,6 +50,9 @@ class LinkerBlockAllocator {
void free(void* block);
void protect_all(int prot);
+ // Purge all pages if all previously allocated blocks have been freed.
+ void purge();
+
private:
void create_new_page();
LinkerBlockAllocatorPage* find_page(void* block);
@@ -57,6 +60,7 @@ class LinkerBlockAllocator {
size_t block_size_;
LinkerBlockAllocatorPage* page_list_;
void* free_block_list_;
+ size_t allocated_;
DISALLOW_COPY_AND_ASSIGN(LinkerBlockAllocator);
};