diff options
Diffstat (limited to 'runtime/mem_map.cc')
-rw-r--r-- | runtime/mem_map.cc | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index e13822a..6566060 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -511,29 +511,26 @@ MemMap::~MemMap() { if (base_begin_ == nullptr && base_size_ == 0) { return; } - - // Remove it from maps_. - { - MutexLock mu(Thread::Current(), *Locks::mem_maps_lock_); - bool found = false; - DCHECK(maps_ != nullptr); - for (auto it = maps_->lower_bound(base_begin_), end = maps_->end(); - it != end && it->first == base_begin_; ++it) { - if (it->second == this) { - found = true; - maps_->erase(it); - break; - } - } - CHECK(found) << "MemMap not found"; - } - if (!reuse_) { int result = munmap(base_begin_, base_size_); if (result == -1) { PLOG(FATAL) << "munmap failed"; } } + + // Remove it from maps_. + MutexLock mu(Thread::Current(), *Locks::mem_maps_lock_); + bool found = false; + DCHECK(maps_ != nullptr); + for (auto it = maps_->lower_bound(base_begin_), end = maps_->end(); + it != end && it->first == base_begin_; ++it) { + if (it->second == this) { + found = true; + maps_->erase(it); + break; + } + } + CHECK(found) << "MemMap not found"; } MemMap::MemMap(const std::string& name, uint8_t* begin, size_t size, void* base_begin, |