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

Unified Diff: mojo/edk/system/channel.cc

Issue 2772373002: [draft] Patch to check potential memory leak (Closed)
Patch Set: double counting Created 3 years, 9 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/trace_event/heap_profiler_allocation_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.cc
diff --git a/mojo/edk/system/channel.cc b/mojo/edk/system/channel.cc
index 8a44d36024e2346b3eab90a48f1eb77a35adcd63..25799caf261b1c50d01ac540fea0a15cdca2a5cb 100644
--- a/mojo/edk/system/channel.cc
+++ b/mojo/edk/system/channel.cc
@@ -22,6 +22,8 @@
#include "base/win/win_util.h"
#endif
+#include "base/atomicops.h"
+
namespace mojo {
namespace edk {
@@ -52,6 +54,8 @@ const size_t kMaxUnusedReadBufferCapacity = 4096;
const size_t kMaxChannelMessageSize = 256 * 1024 * 1024;
const size_t kMaxAttachedHandles = 128;
+static base::subtle::Atomic32 message_count_ = 0;
+
Channel::Message::Message(size_t payload_size, size_t max_handles)
#if defined(MOJO_EDK_LEGACY_PROTOCOL)
: Message(payload_size, max_handles, MessageType::NORMAL_LEGACY) {
@@ -66,6 +70,11 @@ Channel::Message::Message(size_t payload_size,
MessageType message_type)
: max_handles_(max_handles) {
DCHECK_LE(max_handles_, kMaxAttachedHandles);
+ base::subtle::Barrier_AtomicIncrement(&message_count_, 1);
+ if ((message_count_ % 1024) == 0) {
+ LOG(ERROR) << "Message: " << message_count_ << " ["
+ << base::GetCurrentProcId() << "]";
+ }
const bool is_legacy_message = (message_type == MessageType::NORMAL_LEGACY);
size_t extra_header_size = 0;
@@ -136,6 +145,7 @@ Channel::Message::Message(size_t payload_size,
}
Channel::Message::~Message() {
+ base::subtle::Barrier_AtomicIncrement(&message_count_, -1);
base::AlignedFree(data_);
}
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698