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) { |