diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-01-08 11:28:13 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-01-08 16:02:00 -0800 |
commit | 379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b (patch) | |
tree | 680b4173130057a1f70ad321eaf4cfbeba0e291c /runtime/mem_map.cc | |
parent | ca7d89d09294254f16db170a53b0f8dfbf0213ac (diff) | |
download | art-379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b.tar.gz art-379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b.tar.bz2 art-379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b.zip |
Add clamp growth limit
Clamp growth limit shrinks the space memmaps to the current growth
limit. This reduces virtual memory usage for apps with small heaps.
Bug: 18387825
Bug: 17131630
Change-Id: I4a8fdc335d2c40492e991708adabcc46299efb7d
Diffstat (limited to 'runtime/mem_map.cc')
-rw-r--r-- | runtime/mem_map.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 8303f845a8..a722813867 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -665,6 +665,19 @@ void MemMap::Shutdown() { maps_ = nullptr; } +void MemMap::SetSize(size_t new_size) { + if (new_size == base_size_) { + return; + } + CHECK_ALIGNED(new_size, kPageSize); + CHECK_EQ(base_size_, size_) << "Unsupported"; + CHECK_LE(new_size, base_size_); + CHECK_EQ(munmap(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(BaseBegin()) + new_size), + base_size_ - new_size), 0) << new_size << " " << base_size_; + base_size_ = new_size; + size_ = new_size; +} + std::ostream& operator<<(std::ostream& os, const MemMap& mem_map) { os << StringPrintf("[MemMap: %p-%p prot=0x%x %s]", mem_map.BaseBegin(), mem_map.BaseEnd(), mem_map.GetProtect(), |