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

Unified Diff: base/memory/shared_memory_posix.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_posix.cc
diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc
index 3a18faa83dd70e82c8381d33cc247afa270339a9..dfefbe3d20bd12163423cd8cb8bc325e3e84cb9a 100644
--- a/base/memory/shared_memory_posix.cc
+++ b/base/memory/shared_memory_posix.cc
@@ -15,6 +15,7 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/shared_memory_helper.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/safe_strerror.h"
#include "base/process/process_metrics.h"
@@ -284,7 +285,9 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
if (mmap_succeeded) {
mapped_size_ = bytes;
DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
- (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
+ (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
+ if (!SharedMemoryTracker::GetInstance()->IncrementMemoryUsage(*this))
+ return false;
} else {
memory_ = NULL;
}
@@ -297,6 +300,7 @@ bool SharedMemory::Unmap() {
return false;
munmap(memory_, mapped_size_);
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
memory_ = NULL;
mapped_size_ = 0;
return true;
@@ -318,6 +322,7 @@ void SharedMemory::Close() {
if (mapped_file_ > 0) {
if (IGNORE_EINTR(close(mapped_file_)) < 0)
PLOG(ERROR) << "close";
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
mapped_file_ = -1;
}
if (readonly_mapped_file_ > 0) {

Powered by Google App Engine
This is Rietveld 408576698