Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: third_party/tcmalloc/chromium/src/heap-profile-table.cc

Issue 8635003: Fix HEAP_PROFILE_MMAP in google-perftools. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/heap-profile-table.cc
diff --git a/third_party/tcmalloc/chromium/src/heap-profile-table.cc b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
index 893fd4e98a26e365d77fab4dd4460698513c93c8..748aa8c85b4188390bc75cdf3dab6e8b209841df 100644
--- a/third_party/tcmalloc/chromium/src/heap-profile-table.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profile-table.cc
@@ -129,6 +129,11 @@ HeapProfileTable::HeapProfileTable(Allocator alloc, DeAllocator dealloc)
// Make allocation map
allocation_ =
new(alloc_(sizeof(AllocationMap))) AllocationMap(alloc_, dealloc_);
+
+ allocation_mmap_ =
+ new(alloc_(sizeof(AllocationMap))) AllocationMap(alloc_, dealloc_);
+ mmap_record_ = false;
+
// init the rest:
memset(&total_, 0, sizeof(total_));
num_buckets_ = 0;
@@ -139,6 +144,11 @@ HeapProfileTable::~HeapProfileTable() {
allocation_->~AllocationMap();
dealloc_(allocation_);
allocation_ = NULL;
+
+ allocation_mmap_->~AllocationMap();
+ dealloc_(allocation_mmap_);
+ allocation_mmap_ = NULL;
+
// free hash table
for (int b = 0; b < kHashTableSize; b++) {
for (Bucket* x = table_[b]; x != 0; /**/) {
@@ -209,12 +219,22 @@ void HeapProfileTable::RecordAllocWithStack(
AllocValue v;
v.set_bucket(b); // also did set_live(false); set_ignore(false)
v.bytes = bytes;
- allocation_->Insert(ptr, v);
+
+ if(mmap_record_)
+ allocation_mmap_->Insert(ptr, v);
+ else
+ allocation_->Insert(ptr, v);
}
void HeapProfileTable::RecordFree(const void* ptr) {
AllocValue v;
- if (allocation_->FindAndRemove(ptr, &v)) {
+ AllocationMap* a;
+ if(mmap_record_)
+ a = allocation_mmap_;
+ else
+ a = allocation_;
+
+ if(a->FindAndRemove(ptr, &v)){
Bucket* b = v.bucket();
b->frees++;
b->free_size += v.bytes;

Powered by Google App Engine
This is Rietveld 408576698