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

Side by Side Diff: third_party/tcmalloc/chromium/src/deep-heap-profile.h

Issue 10825075: Classify memory usage by allocated type in Deep Memory Profiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: refactored. Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // --- 5 // ---
6 // Author: Sainbayar Sukhbaatar 6 // Author: Sainbayar Sukhbaatar
7 // Dai Mikurube 7 // Dai Mikurube
8 // 8 //
9 // This file contains a class DeepHeapProfile and its public function 9 // This file contains a class DeepHeapProfile and its public function
10 // DeepHeapProfile::FillOrderedProfile() which works as an alternative of 10 // DeepHeapProfile::FillOrderedProfile() which works as an alternative of
11 // HeapProfileTable::FillOrderedProfile(). 11 // HeapProfileTable::FillOrderedProfile().
12 // 12 //
13 // DeepHeapProfile::FillOrderedProfile() dumps more detailed information about 13 // DeepHeapProfile::FillOrderedProfile() dumps more detailed information about
14 // heap usage, which includes OS-level information such as whether the memory 14 // heap usage, which includes OS-level information such as whether the memory
15 // block is actually in memory, or not. DeepHeapProfile::FillOrderedProfile() 15 // block is actually in memory, or not. DeepHeapProfile::FillOrderedProfile()
16 // uses logged data in HeapProfileTable as one of its data sources. 16 // uses logged data in HeapProfileTable as one of its data sources.
17 // DeepHeapProfile works only when its FillOrderedProfile() is called. It has 17 // DeepHeapProfile works only when its FillOrderedProfile() is called. It has
18 // overhead when dumping, but no overhead when logging. 18 // overhead when dumping, but no overhead when logging.
19 // 19 //
20 // It currently works only on Linux. It just delegates to HeapProfileTable in 20 // It currently works only on Linux. It just delegates to HeapProfileTable in
21 // non-Linux environments. 21 // non-Linux environments.
22 22
23 23
24 #ifndef BASE_DEEP_HEAP_PROFILE_H_ 24 #ifndef BASE_DEEP_HEAP_PROFILE_H_
25 #define BASE_DEEP_HEAP_PROFILE_H_ 25 #define BASE_DEEP_HEAP_PROFILE_H_
26 26
27 #include "config.h" 27 #include "config.h"
28 28
29 #if defined(PROFILING_ALLOCATED_TYPE)
30 #include <typeinfo>
31 #endif
32
29 #if defined(__linux__) 33 #if defined(__linux__)
30 #define DEEP_HEAP_PROFILE 1 34 #define DEEP_HEAP_PROFILE 1
31 #endif 35 #endif
32 36
33 #include "addressmap-inl.h" 37 #include "addressmap-inl.h"
34 #include "heap-profile-table.h" 38 #include "heap-profile-table.h"
35 39
36 class DeepHeapProfile { 40 class DeepHeapProfile {
37 public: 41 public:
38 typedef HeapProfileTable::Bucket Bucket; 42 typedef HeapProfileTable::Bucket Bucket;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // of HeapProfileTable::FillOrderedProfile. 84 // of HeapProfileTable::FillOrderedProfile.
81 // 85 //
82 // The profile buckets are dumped in the decreasing order of currently 86 // The profile buckets are dumped in the decreasing order of currently
83 // allocated bytes. We do not provision for 0-terminating |buffer|. 87 // allocated bytes. We do not provision for 0-terminating |buffer|.
84 int FillOrderedProfile(char buffer[], int buffer_size); 88 int FillOrderedProfile(char buffer[], int buffer_size);
85 89
86 private: 90 private:
87 #ifdef DEEP_HEAP_PROFILE 91 #ifdef DEEP_HEAP_PROFILE
88 struct DeepBucket { 92 struct DeepBucket {
89 Bucket* bucket; 93 Bucket* bucket;
94 #if defined(PROFILING_ALLOCATED_TYPE)
95 const std::type_info* type;
M-A Ruel 2012/08/19 02:40:00 Note that type_info won't be useful on Windows sin
Dai Mikurube (NOT FULLTIME) 2012/08/20 10:35:27 I know. PROFILING_ALLOCATED_TYPE is always used w
96 #endif
90 size_t committed_size; 97 size_t committed_size;
91 bool is_mmap; 98 bool is_mmap;
92 int id; // Unique ID of the bucket. 99 int id; // Unique ID of the bucket.
93 bool is_logged; // True if the stracktrace is logged to a file. 100 bool is_logged; // True if the stracktrace is logged to a file.
94 DeepBucket* next; // Next entry in hash-table. 101 DeepBucket* next; // Next entry in hash-table.
95 }; 102 };
96 103
97 typedef AddressMap<DeepBucket> DeepBucketMap; 104 typedef AddressMap<DeepBucket> DeepBucketMap;
98 105
99 struct PageState { 106 struct PageState {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 GlobalStats* stats, 208 GlobalStats* stats,
202 MMapListEntry* mmap_list, 209 MMapListEntry* mmap_list,
203 int mmap_list_length); 210 int mmap_list_length);
204 211
205 // Add a uintptr_t integer to a hash-value for GetDeepBucket. 212 // Add a uintptr_t integer to a hash-value for GetDeepBucket.
206 inline static void AddIntegerToHashValue( 213 inline static void AddIntegerToHashValue(
207 uintptr_t add, uintptr_t* hash_value); 214 uintptr_t add, uintptr_t* hash_value);
208 215
209 // Get the DeepBucket object corresponding to the given |bucket|. 216 // Get the DeepBucket object corresponding to the given |bucket|.
210 // DeepBucket is an extension to Bucket which is declared above. 217 // DeepBucket is an extension to Bucket which is declared above.
211 DeepBucket* GetDeepBucket(Bucket* bucket, bool is_mmap, DeepBucket** table); 218 DeepBucket* GetDeepBucket(Bucket* bucket, bool is_mmap,
219 #if defined(PROFILING_ALLOCATED_TYPE)
220 const std::type_info* type,
221 #endif
222 DeepBucket** table);
212 223
213 // Reset committed_size member variables in DeepBucket objects to 0. 224 // Reset committed_size member variables in DeepBucket objects to 0.
214 void ResetCommittedSize(DeepBucket** deep_table); 225 void ResetCommittedSize(DeepBucket** deep_table);
215 226
216 // Fill bucket data in |bucket_table| into buffer |buffer| of size 227 // Fill bucket data in |bucket_table| into buffer |buffer| of size
217 // |buffer_size|, and return the size occupied by the bucket data in 228 // |buffer_size|, and return the size occupied by the bucket data in
218 // |buffer|. |bucket_length| is the offset for |buffer| to start filling. 229 // |buffer|. |bucket_length| is the offset for |buffer| to start filling.
219 int SnapshotBucketTableWithoutMalloc(DeepBucket** deep_table, 230 int SnapshotBucketTableWithoutMalloc(DeepBucket** deep_table,
220 int used_in_buffer, 231 int used_in_buffer,
221 int buffer_size, 232 int buffer_size,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 int mmap_list_length_; 297 int mmap_list_length_;
287 int num_mmap_allocations_; 298 int num_mmap_allocations_;
288 #endif // DEEP_HEAP_PROFILE 299 #endif // DEEP_HEAP_PROFILE
289 300
290 HeapProfileTable* heap_profile_; 301 HeapProfileTable* heap_profile_;
291 302
292 DISALLOW_COPY_AND_ASSIGN(DeepHeapProfile); 303 DISALLOW_COPY_AND_ASSIGN(DeepHeapProfile);
293 }; 304 };
294 305
295 #endif // BASE_DEEP_HEAP_PROFILE_H_ 306 #endif // BASE_DEEP_HEAP_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698