diff options
| author | 2014-07-25 19:06:45 +0000 | |
|---|---|---|
| committer | 2014-07-24 22:43:23 +0000 | |
| commit | 9c81c0cb0dc8c8d8ae5dca3d2d82b0eec7af589f (patch) | |
| tree | fe73fdfc344333a33e1f6001b90d9649d6dfea1d | |
| parent | d190d989ac92d2a5b9a342692564f40bd2080895 (diff) | |
| parent | 2796a1669ae0f3b96db8432fbd8be1b93bf335c4 (diff) | |
Merge "Fix main space memory leak and add checks."
| -rw-r--r-- | runtime/gc/heap.cc | 15 | ||||
| -rw-r--r-- | runtime/gc/space/malloc_space.cc | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 33ff3bb1f2..1d80833b63 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -692,7 +692,7 @@ void Heap::AddSpace(space::Space* space) { accounting::ContinuousSpaceBitmap* live_bitmap = continuous_space->GetLiveBitmap(); accounting::ContinuousSpaceBitmap* mark_bitmap = continuous_space->GetMarkBitmap(); if (live_bitmap != nullptr) { - DCHECK(mark_bitmap != nullptr); + CHECK(mark_bitmap != nullptr); live_bitmap_->AddContinuousSpaceBitmap(live_bitmap); mark_bitmap_->AddContinuousSpaceBitmap(mark_bitmap); } @@ -703,7 +703,7 @@ void Heap::AddSpace(space::Space* space) { return a->Begin() < b->Begin(); }); } else { - DCHECK(space->IsDiscontinuousSpace()); + CHECK(space->IsDiscontinuousSpace()); space::DiscontinuousSpace* discontinuous_space = space->AsDiscontinuousSpace(); live_bitmap_->AddLargeObjectBitmap(discontinuous_space->GetLiveBitmap()); mark_bitmap_->AddLargeObjectBitmap(discontinuous_space->GetMarkBitmap()); @@ -1595,19 +1595,20 @@ void Heap::TransitionCollector(CollectorType collector_type) { Compact(bump_pointer_space_, main_space_, kGcCauseCollectorTransition); // Use the now empty main space mem map for the bump pointer temp space. mem_map.reset(main_space_->ReleaseMemMap()); - // Remove the main space so that we don't try to trim it, this doens't work for debug - // builds since RosAlloc attempts to read the magic number from a protected page. - RemoveSpace(main_space_); // Unset the pointers just in case. if (dlmalloc_space_ == main_space_) { dlmalloc_space_ = nullptr; } else if (rosalloc_space_ == main_space_) { rosalloc_space_ = nullptr; } + // Remove the main space so that we don't try to trim it, this doens't work for debug + // builds since RosAlloc attempts to read the magic number from a protected page. + RemoveSpace(main_space_); RemoveRememberedSet(main_space_); - RemoveRememberedSet(main_space_backup_.get()); - main_space_backup_.reset(nullptr); + delete main_space_; // Delete the space since it has been removed. main_space_ = nullptr; + RemoveRememberedSet(main_space_backup_.get()); + main_space_backup_.reset(nullptr); // Deletes the space. temp_space_ = space::BumpPointerSpace::CreateFromMemMap("Bump pointer space 2", mem_map.release()); AddSpace(temp_space_); diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc index 27f92b571e..ba7e5c1eca 100644 --- a/runtime/gc/space/malloc_space.cc +++ b/runtime/gc/space/malloc_space.cc @@ -51,12 +51,12 @@ MallocSpace::MallocSpace(const std::string& name, MemMap* mem_map, live_bitmap_.reset(accounting::ContinuousSpaceBitmap::Create( StringPrintf("allocspace %s live-bitmap %d", name.c_str(), static_cast<int>(bitmap_index)), Begin(), NonGrowthLimitCapacity())); - DCHECK(live_bitmap_.get() != nullptr) << "could not create allocspace live bitmap #" + CHECK(live_bitmap_.get() != nullptr) << "could not create allocspace live bitmap #" << bitmap_index; mark_bitmap_.reset(accounting::ContinuousSpaceBitmap::Create( StringPrintf("allocspace %s mark-bitmap %d", name.c_str(), static_cast<int>(bitmap_index)), Begin(), NonGrowthLimitCapacity())); - DCHECK(live_bitmap_.get() != nullptr) << "could not create allocspace mark bitmap #" + CHECK(live_bitmap_.get() != nullptr) << "could not create allocspace mark bitmap #" << bitmap_index; } for (auto& freed : recent_freed_objects_) { |