Fix regression in ModUnionTable RAM usage
We forgot to check if a reference changed before assigning it back,
this caused extra dirty pages in the image.
BusinessCard .art PSS
Before: 1678 KB
After: 991 KB
System wide .art PSS goes down ~20MB on my shamu.
Bug: 27906566
(cherry picked from commit 014885a8561f2415cb19ebde1e4084b88d63b746)
Change-Id: I64d149f10f3ef1ed1cb61810282559b47823014c
diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc
index d16afd9..4e40aea 100644
--- a/runtime/gc/accounting/mod_union_table.cc
+++ b/runtime/gc/accounting/mod_union_table.cc
@@ -210,7 +210,11 @@
if (mod_union_table_->ShouldAddReference(root->AsMirrorPtr())) {
*has_target_reference_ = true;
// TODO: Add MarkCompressedReference callback here.
- root->Assign(visitor_->MarkObject(root->AsMirrorPtr()));
+ mirror::Object* old_ref = root->AsMirrorPtr();
+ mirror::Object* new_ref = visitor_->MarkObject(old_ref);
+ if (old_ref != new_ref) {
+ root->Assign(new_ref);
+ }
}
}
diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h
index b61bef7..c19107a 100644
--- a/runtime/gc/collector/mark_sweep.h
+++ b/runtime/gc/collector/mark_sweep.h
@@ -231,7 +231,7 @@
protected:
// Returns object if the object is marked in the heap bitmap, otherwise null.
virtual mirror::Object* IsMarked(mirror::Object* object) OVERRIDE
- SHARED_REQUIRES(Locks::heap_bitmap_lock_);
+ SHARED_REQUIRES(Locks::heap_bitmap_lock_, Locks::mutator_lock_);
void MarkObjectNonNull(mirror::Object* obj,
mirror::Object* holder = nullptr,