Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file defines structs to accumulate memory allocation and deallocation | |
| 6 // counts. These structs are commonly used for malloc (in HeapProfileTable) | |
| 7 // and mmap (in MemoryRegionMap). | |
| 8 | |
| 9 #ifndef HEAP_PROFILE_STATS_H_ | |
| 10 #define HEAP_PROFILE_STATS_H_ | |
| 11 | |
| 12 struct HeapProfileStats { | |
| 13 int32 allocs; // Number of allocation calls. | |
|
Alexander Potapenko
2013/03/07 14:50:52
Again, methods before members and DISALLOW_COPY_AN
Dai Mikurube (NOT FULLTIME)
2013/03/07 17:14:24
Reordered. And, I don't add DISALLOW_COPY_AND_ASS
| |
| 14 int32 frees; // Number of free calls. | |
| 15 int64 alloc_size; // Total size of all allocated objects so far. | |
| 16 int64 free_size; // Total size of all freed objects so far. | |
| 17 | |
| 18 // Returns true if the two HeapProfileStats are semantically equal. | |
| 19 bool Equivalent(const HeapProfileStats& x) const { | |
| 20 return allocs - frees == x.allocs - x.frees && | |
| 21 alloc_size - free_size == x.alloc_size - x.free_size; | |
| 22 } | |
| 23 }; | |
| 24 | |
| 25 // Allocation and deallocation statistics per each stack trace. | |
| 26 struct HeapProfileBucket : public HeapProfileStats { | |
| 27 // Longest stack trace we record. | |
| 28 static const int kMaxStackDepth = 32; | |
| 29 | |
| 30 uintptr_t hash; // Hash value of the stack trace. | |
| 31 int depth; // Depth of stack trace. | |
| 32 const void** stack; // Stack trace. | |
| 33 HeapProfileBucket* next; // Next entry in hash-table. | |
| 34 }; | |
| 35 | |
| 36 #endif // HEAP_PROFILE_STATS_H_ | |
| OLD | NEW |