OLD | NEW |
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 #include "base/trace_event/malloc_dump_provider.h" | 5 #include "base/trace_event/malloc_dump_provider.h" |
6 | 6 |
7 #include <malloc.h> | 7 #include <malloc.h> |
8 | 8 |
9 #include "base/trace_event/process_memory_dump.h" | 9 #include "base/trace_event/process_memory_dump.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 ProcessMemoryDump* pmd) { | 32 ProcessMemoryDump* pmd) { |
33 struct mallinfo info = mallinfo(); | 33 struct mallinfo info = mallinfo(); |
34 DCHECK_GE(info.arena + info.hblkhd, info.uordblks); | 34 DCHECK_GE(info.arena + info.hblkhd, info.uordblks); |
35 | 35 |
36 // When the system allocator is implemented by tcmalloc, the total heap | 36 // When the system allocator is implemented by tcmalloc, the total heap |
37 // size is given by |arena| and |hblkhd| is 0. In case of Android's jemalloc | 37 // size is given by |arena| and |hblkhd| is 0. In case of Android's jemalloc |
38 // |arena| is 0 and the outer pages size is reported by |hblkhd|. In case of | 38 // |arena| is 0 and the outer pages size is reported by |hblkhd|. In case of |
39 // dlmalloc the total is given by |arena| + |hblkhd|. | 39 // dlmalloc the total is given by |arena| + |hblkhd|. |
40 // For more details see link: http://goo.gl/fMR8lF. | 40 // For more details see link: http://goo.gl/fMR8lF. |
41 MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc"); | 41 MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc"); |
42 outer_dump->AddScalar("heap_virtual_size", | 42 outer_dump->AddScalar("virtual_size", |
43 MemoryAllocatorDump::kUnitsBytes, | 43 MemoryAllocatorDump::kUnitsBytes, |
44 info.arena + info.hblkhd); | 44 info.arena + info.hblkhd); |
45 | 45 |
46 // Total allocated space is given by |uordblks|. | 46 // Total allocated space is given by |uordblks|. |
47 MemoryAllocatorDump* inner_dump = pmd->CreateAllocatorDump(kAllocatedObjects); | 47 MemoryAllocatorDump* inner_dump = pmd->CreateAllocatorDump(kAllocatedObjects); |
48 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize, | 48 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize, |
49 MemoryAllocatorDump::kUnitsBytes, info.uordblks); | 49 MemoryAllocatorDump::kUnitsBytes, info.uordblks); |
50 | 50 |
51 return true; | 51 return true; |
52 } | 52 } |
53 | 53 |
54 } // namespace trace_event | 54 } // namespace trace_event |
55 } // namespace base | 55 } // namespace base |
OLD | NEW |