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

Unified Diff: base/memory/shared_memory_win.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_win.cc
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc
index 1eba23b846b8da56377f2c88a9cf37e287325faa..8a2535ad338d4f7d3d53e4304115db9e8e5b9352 100644
--- a/base/memory/shared_memory_win.cc
+++ b/base/memory/shared_memory_win.cc
@@ -9,6 +9,7 @@
#include <stdint.h>
#include "base/logging.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
@@ -326,8 +327,9 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
static_cast<uint64_t>(offset) >> 32, static_cast<DWORD>(offset), bytes);
if (memory_ != NULL) {
DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
- (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
+ (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
mapped_size_ = GetMemorySectionSize(memory_);
+ SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this);
return true;
}
return false;
@@ -338,6 +340,7 @@ bool SharedMemory::Unmap() {
return false;
UnmapViewOfFile(memory_);
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
memory_ = NULL;
return true;
}
@@ -377,6 +380,7 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
void SharedMemory::Close() {
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
Primiano Tucci (use gerrit) 2017/01/20 16:34:52 see my prev comment about close vs unmap. I think
hajimehoshi 2017/01/23 11:59:09 Done.
mapped_file_.Close();
}

Powered by Google App Engine
This is Rietveld 408576698