OLD | NEW |
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Release a previously taken snapshot. snapshot must not | 174 // Release a previously taken snapshot. snapshot must not |
175 // be used after this call. | 175 // be used after this call. |
176 void ReleaseSnapshot(Snapshot* snapshot); | 176 void ReleaseSnapshot(Snapshot* snapshot); |
177 | 177 |
178 // Return a snapshot of every non-live, non-ignored object in *this. | 178 // Return a snapshot of every non-live, non-ignored object in *this. |
179 // If "base" is non-NULL, skip any objects present in "base". | 179 // If "base" is non-NULL, skip any objects present in "base". |
180 // As a side-effect, clears the "live" bit on every live object in *this. | 180 // As a side-effect, clears the "live" bit on every live object in *this. |
181 // Caller must call ReleaseSnapshot() on result when no longer needed. | 181 // Caller must call ReleaseSnapshot() on result when no longer needed. |
182 Snapshot* NonLiveSnapshot(Snapshot* base); | 182 Snapshot* NonLiveSnapshot(Snapshot* base); |
183 | 183 |
| 184 void MMapRecordBegin() { mmap_record_ = true; } |
| 185 void MMapRecordEnd() { mmap_record_ = false; } |
| 186 |
184 private: | 187 private: |
185 | 188 |
186 // data types ---------------------------- | 189 // data types ---------------------------- |
187 | 190 |
188 // Hash table bucket to hold (de)allocation stats | 191 // Hash table bucket to hold (de)allocation stats |
189 // for a given allocation call stack trace. | 192 // for a given allocation call stack trace. |
190 struct Bucket : public Stats { | 193 struct Bucket : public Stats { |
191 uintptr_t hash; // Hash value of the stack trace | 194 uintptr_t hash; // Hash value of the stack trace |
192 int depth; // Depth of stack trace | 195 int depth; // Depth of stack trace |
193 const void** stack; // Stack trace | 196 const void** stack; // Stack trace |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 321 |
319 // Bucket hash table. | 322 // Bucket hash table. |
320 // We hand-craft one instead of using one of the pre-written | 323 // We hand-craft one instead of using one of the pre-written |
321 // ones because we do not want to use malloc when operating on the table. | 324 // ones because we do not want to use malloc when operating on the table. |
322 // It is only few lines of code, so no big deal. | 325 // It is only few lines of code, so no big deal. |
323 Bucket** table_; | 326 Bucket** table_; |
324 int num_buckets_; | 327 int num_buckets_; |
325 | 328 |
326 // Map of all currently allocated objects we know about. | 329 // Map of all currently allocated objects we know about. |
327 AllocationMap* allocation_; | 330 AllocationMap* allocation_; |
| 331 // Mmap allocations are saved in a separate map |
| 332 // because mmap and tcmalloc allocations could have the same address |
| 333 AllocationMap* allocation_mmap_; |
| 334 bool mmap_record_; |
328 | 335 |
329 DISALLOW_COPY_AND_ASSIGN(HeapProfileTable); | 336 DISALLOW_COPY_AND_ASSIGN(HeapProfileTable); |
330 }; | 337 }; |
331 | 338 |
332 class HeapProfileTable::Snapshot { | 339 class HeapProfileTable::Snapshot { |
333 public: | 340 public: |
334 const Stats& total() const { return total_; } | 341 const Stats& total() const { return total_; } |
335 | 342 |
336 // Report anything in this snapshot as a leak. | 343 // Report anything in this snapshot as a leak. |
337 // May use new/delete for temporary storage. | 344 // May use new/delete for temporary storage. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // Helpers for sorting and generating leak reports | 382 // Helpers for sorting and generating leak reports |
376 struct Entry; | 383 struct Entry; |
377 struct ReportState; | 384 struct ReportState; |
378 static void ReportCallback(const void* ptr, AllocValue* v, ReportState*); | 385 static void ReportCallback(const void* ptr, AllocValue* v, ReportState*); |
379 static void ReportObject(const void* ptr, AllocValue* v, char*); | 386 static void ReportObject(const void* ptr, AllocValue* v, char*); |
380 | 387 |
381 DISALLOW_COPY_AND_ASSIGN(Snapshot); | 388 DISALLOW_COPY_AND_ASSIGN(Snapshot); |
382 }; | 389 }; |
383 | 390 |
384 #endif // BASE_HEAP_PROFILE_TABLE_H_ | 391 #endif // BASE_HEAP_PROFILE_TABLE_H_ |
OLD | NEW |