Add allocation stack traces for HPROF dump.
This feature is currently only enabled when DDMS's allocation tracking
is enabled. In the future there should be a way to enable this feature
before an application starts.
Also updates DDMS's recent allocation tracking to use a new backend
data structure that is shared with this feature.
The following system properties controls customizable parameters:
dalvik.vm.allocTrackerMax: max number of objects that have allocation
records, default 512K;
dalvik.vm.recentAllocMax: max number of records that are sent to DDMS
when clicking "Get allocation" button,
default 64K-1 (limit of the protocol);
dalvik.vm.allocStackDepth: max number of stack frames in an allocation
record, default 4.
Bug: 20037135
Change-Id: I26ed378a5613678bd3c43e846025f90470a8e059
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9d651bf..cb7f5f3 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -402,6 +402,7 @@
GetInternTable()->SweepInternTableWeaks(visitor, arg);
GetMonitorList()->SweepMonitorList(visitor, arg);
GetJavaVM()->SweepJniWeakGlobals(visitor, arg);
+ GetHeap()->SweepAllocationRecords(visitor, arg);
}
bool Runtime::Create(const RuntimeOptions& options, bool ignore_unrecognized) {
@@ -1471,6 +1472,11 @@
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.
}
void Runtime::AllowNewSystemWeaks() {