summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-03-27 07:36:59 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-03-27 07:37:00 +0000
commit175cac4c1778474d674204f928ccc64c21c165cd (patch)
tree3be15558544a771a0a94c767e4bbba4f9b01cad4 /runtime
parent636583c586b78e188168e510452cef0645578f8d (diff)
parentb98063a4d54c5a741152a1eebc262d8e223b3b25 (diff)
downloadart-175cac4c1778474d674204f928ccc64c21c165cd.zip
art-175cac4c1778474d674204f928ccc64c21c165cd.tar.gz
art-175cac4c1778474d674204f928ccc64c21c165cd.tar.bz2
Merge "Fix alloc tracker locking issue"
Diffstat (limited to 'runtime')
-rw-r--r--runtime/debugger.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index c18d5c6..1ff2003 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -3767,22 +3767,27 @@ static size_t GetAllocTrackerMax() {
}
void Dbg::SetAllocTrackingEnabled(bool enabled) {
- MutexLock mu(Thread::Current(), *alloc_tracker_lock_);
if (enabled) {
- if (recent_allocation_records_ == NULL) {
- alloc_record_max_ = GetAllocTrackerMax();
- LOG(INFO) << "Enabling alloc tracker (" << alloc_record_max_ << " entries of "
- << kMaxAllocRecordStackDepth << " frames, taking "
- << PrettySize(sizeof(AllocRecord) * alloc_record_max_) << ")";
- alloc_record_head_ = alloc_record_count_ = 0;
- recent_allocation_records_ = new AllocRecord[alloc_record_max_];
- CHECK(recent_allocation_records_ != NULL);
+ {
+ MutexLock mu(Thread::Current(), *alloc_tracker_lock_);
+ if (recent_allocation_records_ == NULL) {
+ alloc_record_max_ = GetAllocTrackerMax();
+ LOG(INFO) << "Enabling alloc tracker (" << alloc_record_max_ << " entries of "
+ << kMaxAllocRecordStackDepth << " frames, taking "
+ << PrettySize(sizeof(AllocRecord) * alloc_record_max_) << ")";
+ alloc_record_head_ = alloc_record_count_ = 0;
+ recent_allocation_records_ = new AllocRecord[alloc_record_max_];
+ CHECK(recent_allocation_records_ != NULL);
+ }
}
Runtime::Current()->GetInstrumentation()->InstrumentQuickAllocEntryPoints();
} else {
Runtime::Current()->GetInstrumentation()->UninstrumentQuickAllocEntryPoints();
- delete[] recent_allocation_records_;
- recent_allocation_records_ = NULL;
+ {
+ MutexLock mu(Thread::Current(), *alloc_tracker_lock_);
+ delete[] recent_allocation_records_;
+ recent_allocation_records_ = NULL;
+ }
}
}