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

Unified Diff: base/memory/shared_memory_tracker.h

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) 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/memory/shared_memory_posix.cc ('k') | base/memory/shared_memory_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_tracker.h
diff --git a/base/memory/shared_memory_tracker.h b/base/memory/shared_memory_tracker.h
index 039e48d515fafc1fe2b49bcee9f743d485de3454..e0ff268320c5ffccd2bb1e1c83a264514767d4cc 100644
--- a/base/memory/shared_memory_tracker.h
+++ b/base/memory/shared_memory_tracker.h
@@ -14,6 +14,7 @@
namespace base {
namespace trace_event {
+class MemoryAllocatorDumpGuid;
class ProcessMemoryDump;
}
@@ -24,6 +25,14 @@ class BASE_EXPORT SharedMemoryTracker
// Returns a singleton instance.
static SharedMemoryTracker* GetInstance();
+ // Adds two ownership edges between the given guid |source| and its global
+ // shared memory dump. This helps to get accurate effective size of modules
+ // that backend is shared memory.
+ static bool AddOwnershipEdges(
+ trace_event::ProcessMemoryDump* pmd,
+ const trace_event::MemoryAllocatorDumpGuid& source,
+ const SharedMemory& shared_memory);
+
// Records shared memory usage on mapping.
void IncrementMemoryUsage(const SharedMemory& shared_memory);
@@ -31,24 +40,16 @@ class BASE_EXPORT SharedMemoryTracker
void DecrementMemoryUsage(const SharedMemory& shared_memory);
private:
- struct Usage {
- Usage();
- Usage(const Usage& rhs);
- ~Usage();
- SharedMemory::UniqueId unique_id;
- size_t size;
- };
-
SharedMemoryTracker();
~SharedMemoryTracker() override;
// base::trace_event::MemoryDumpProvider implementation.
- bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
- base::trace_event::ProcessMemoryDump* pmd) override;
+ bool OnMemoryDump(const trace_event::MemoryDumpArgs& args,
+ trace_event::ProcessMemoryDump* pmd) override;
// Used to lock when |usages_| is modified or read.
Lock usages_lock_;
- std::unordered_map<const SharedMemory*, Usage> usages_;
+ std::unordered_map<const SharedMemory*, size_t> usages_;
DISALLOW_COPY_AND_ASSIGN(SharedMemoryTracker);
};
« no previous file with comments | « base/memory/shared_memory_posix.cc ('k') | base/memory/shared_memory_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698