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

Side by Side Diff: base/trace_event/malloc_dump_provider.h

Issue 2350423003: [Tentaive patch for discussion] Add Purge+Suspend metrics as UMA.
Patch Set: Add v8 heap usage Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_ 5 #ifndef BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
6 #define BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_ 6 #define BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
7 7
8 #include <istream> 8 #include <istream>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "base/trace_event/memory_dump_provider.h" 15 #include "base/trace_event/memory_dump_provider.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) || \ 18 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WIN) || \
19 (defined(OS_MACOSX) && !defined(OS_IOS)) 19 (defined(OS_MACOSX) && !defined(OS_IOS))
20 #define MALLOC_MEMORY_TRACING_SUPPORTED 20 #define MALLOC_MEMORY_TRACING_SUPPORTED
21 #endif 21 #endif
22 22
23 namespace base { 23 namespace base {
24 namespace trace_event { 24 namespace trace_event {
25 25
26 class AllocationRegister; 26 class AllocationRegister;
27 27
28 struct MallocStatistics {
29 size_t allocated_objects_size;
30 size_t allocated_objects_count;
31 size_t metadata_fragmentation_caches;
32 size_t total_virtual_size;
33 size_t resident_size;
34
35 MallocStatistics()
36 : allocated_objects_size(0),
37 allocated_objects_count(0),
38 metadata_fragmentation_caches(0),
39 total_virtual_size(0),
40 resident_size(0) {}
41 };
42
28 // Dump provider which collects process-wide memory stats. 43 // Dump provider which collects process-wide memory stats.
29 class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider { 44 class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider {
30 public: 45 public:
31 // Name of the allocated_objects dump. Use this to declare suballocator dumps 46 // Name of the allocated_objects dump. Use this to declare suballocator dumps
32 // from other dump providers. 47 // from other dump providers.
33 static const char kAllocatedObjects[]; 48 static const char kAllocatedObjects[];
34 49
35 static MallocDumpProvider* GetInstance(); 50 static MallocDumpProvider* GetInstance();
36 51
52 static MallocStatistics GetStatistics();
bashi 2016/09/22 23:28:26 I'd propose to have a separate base/memory/malloc_
53
37 // MemoryDumpProvider implementation. 54 // MemoryDumpProvider implementation.
38 bool OnMemoryDump(const MemoryDumpArgs& args, 55 bool OnMemoryDump(const MemoryDumpArgs& args,
39 ProcessMemoryDump* pmd) override; 56 ProcessMemoryDump* pmd) override;
40 57
41 void OnHeapProfilingEnabled(bool enabled) override; 58 void OnHeapProfilingEnabled(bool enabled) override;
42 59
43 // For heap profiling. 60 // For heap profiling.
44 void InsertAllocation(void* address, size_t size); 61 void InsertAllocation(void* address, size_t size);
45 void RemoveAllocation(void* address); 62 void RemoveAllocation(void* address);
46 63
(...skipping 13 matching lines...) Expand all
60 // generation is malloc/new-ing for its own bookeeping data structures. 77 // generation is malloc/new-ing for its own bookeeping data structures.
61 PlatformThreadId tid_dumping_heap_; 78 PlatformThreadId tid_dumping_heap_;
62 79
63 DISALLOW_COPY_AND_ASSIGN(MallocDumpProvider); 80 DISALLOW_COPY_AND_ASSIGN(MallocDumpProvider);
64 }; 81 };
65 82
66 } // namespace trace_event 83 } // namespace trace_event
67 } // namespace base 84 } // namespace base
68 85
69 #endif // BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_ 86 #endif // BASE_TRACE_EVENT_MALLOC_DUMP_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/malloc_dump_provider.cc » ('j') | content/child/child_discardable_shared_memory_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698