Make allocation tracker use less memory
The allocation tracker no longer keeps recently allocated objects live.
Instead it just keeps their class objects live as strong roots. This fixed
the gc-stress test failure for 098-ddmc.
Also fixed the issue in DisableNewSystemWeak() for allocation tracker,
by making new allocation to wait until GC's sweeping to complete. I didn't
feel any significant slowdown with this wait.
Bug: 20037135
Change-Id: I6a98188832cf7ee478007e3788e742dc6e18f7b8
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index d0f01b3..96c15ea 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1483,17 +1483,14 @@
monitor_list_->DisallowNewMonitors();
intern_table_->DisallowNewInterns();
java_vm_->DisallowNewWeakGlobals();
- // TODO: add a similar call for heap.allocation_records_, otherwise some of the newly allocated
- // objects that are not marked might be swept from the records, making the records incomplete.
- // It is safe for now since the only effect is that those objects do not have allocation records.
- // The number of such objects should be small, and current allocation tracker cannot collect
- // allocation records for all objects anyway.
+ heap_->DisallowNewAllocationRecords();
}
void Runtime::AllowNewSystemWeaks() {
monitor_list_->AllowNewMonitors();
intern_table_->AllowNewInterns();
java_vm_->AllowNewWeakGlobals();
+ heap_->AllowNewAllocationRecords();
}
void Runtime::EnsureNewSystemWeaksDisallowed() {
@@ -1502,6 +1499,7 @@
monitor_list_->EnsureNewMonitorsDisallowed();
intern_table_->EnsureNewInternsDisallowed();
java_vm_->EnsureNewWeakGlobalsDisallowed();
+ heap_->EnsureNewAllocationRecordsDisallowed();
}
void Runtime::SetInstructionSet(InstructionSet instruction_set) {