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

Unified Diff: base/memory/shared_memory_mac.cc

Issue 2867193004: Recode shared memory usage on Windows, macOS and NaCl (Closed)
Patch Set: Move decrementing before unmapping Created 3 years, 7 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
« no previous file with comments | « base/BUILD.gn ('k') | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_mac.cc
diff --git a/base/memory/shared_memory_mac.cc b/base/memory/shared_memory_mac.cc
index 8237b44411ca34cd5913d58d699398fad4f0f8cf..9719e9720ca8f84c6ed4c30a1576a00f20722a55 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"
@@ -205,6 +206,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 {
last_error_ = SharedMemoryError::MMAP_FAILED;
memory_ = NULL;
@@ -217,6 +219,7 @@ bool SharedMemory::Unmap() {
if (memory_ == NULL)
return false;
+ SharedMemoryTracker::GetInstance()->DecrementMemoryUsage(*this);
switch (mapped_memory_mechanism_) {
case SharedMemoryHandle::POSIX:
munmap(memory_, mapped_size_);
@@ -227,7 +230,6 @@ bool SharedMemory::Unmap() {
mapped_size_);
break;
}
-
memory_ = NULL;
mapped_size_ = 0;
return true;
« no previous file with comments | « base/BUILD.gn ('k') | base/memory/shared_memory_nacl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698