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

Unified Diff: base/memory/shared_memory_mac.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Implement buckets Created 3 years, 11 months 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: base/memory/shared_memory_mac.cc
diff --git a/base/memory/shared_memory_mac.cc b/base/memory/shared_memory_mac.cc
index d376daa579ee0aec81ceddf0531031ff2cf376fc..2377e57f615071d16c2453646e57ed052d466c75 100644
--- a/base/memory/shared_memory_mac.cc
+++ b/base/memory/shared_memory_mac.cc
@@ -17,6 +17,7 @@
#include "base/mac/mac_util.h"
#include "base/mac/scoped_mach_vm.h"
#include "base/memory/shared_memory_helper.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h"
#include "base/posix/eintr_wrapper.h"
@@ -212,6 +213,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
(SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
mapped_memory_mechanism_ = shm_.type_;
+ SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this);
} else {
memory_ = NULL;
}
@@ -233,7 +235,7 @@ bool SharedMemory::Unmap() {
mapped_size_);
break;
}
-
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
memory_ = NULL;
mapped_size_ = 0;
return true;
@@ -256,6 +258,7 @@ SharedMemoryHandle SharedMemory::TakeHandle() {
}
void SharedMemory::Close() {
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
Primiano Tucci (use gerrit) 2017/01/20 16:34:52 I think this might not be the right point. The dec
hajimehoshi 2017/01/23 11:59:09 I was wondering if the file descriptor's is still
shm_.Close();
shm_ = SharedMemoryHandle();
if (shm_.type_ == SharedMemoryHandle::POSIX) {

Powered by Google App Engine
This is Rietveld 408576698