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

Side by Side Diff: base/trace_event/java_heap_dump_provider_android.cc

Issue 1105143003: [tracing] Simplify the MemoryAllocatorDump API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplif_2
Patch Set: Fix Win build Created 5 years, 7 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
« no previous file with comments | « no previous file | base/trace_event/malloc_dump_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/trace_event/java_heap_dump_provider_android.h" 5 #include "base/trace_event/java_heap_dump_provider_android.h"
6 6
7 #include "base/android/java_runtime.h" 7 #include "base/android/java_runtime.h"
8 #include "base/trace_event/process_memory_dump.h" 8 #include "base/trace_event/process_memory_dump.h"
9 9
10 namespace base { 10 namespace base {
11 namespace trace_event { 11 namespace trace_event {
12 12
13 namespace {
14
15 const char kDumperName[] = "java_heap";
16
17 } // namespace
18
19 // static 13 // static
20 JavaHeapDumpProvider* JavaHeapDumpProvider::GetInstance() { 14 JavaHeapDumpProvider* JavaHeapDumpProvider::GetInstance() {
21 return Singleton<JavaHeapDumpProvider, 15 return Singleton<JavaHeapDumpProvider,
22 LeakySingletonTraits<JavaHeapDumpProvider>>::get(); 16 LeakySingletonTraits<JavaHeapDumpProvider>>::get();
23 } 17 }
24 18
25 JavaHeapDumpProvider::JavaHeapDumpProvider() { 19 JavaHeapDumpProvider::JavaHeapDumpProvider() {
26 } 20 }
27 21
28 JavaHeapDumpProvider::~JavaHeapDumpProvider() { 22 JavaHeapDumpProvider::~JavaHeapDumpProvider() {
29 } 23 }
30 24
31 // Called at trace dump point time. Creates a snapshot with the memory counters 25 // Called at trace dump point time. Creates a snapshot with the memory counters
32 // for the current process. 26 // for the current process.
33 bool JavaHeapDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) { 27 bool JavaHeapDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) {
34 MemoryAllocatorDump* dump = 28 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump("java_heap");
35 pmd->CreateAllocatorDump(kDumperName, MemoryAllocatorDump::kRootHeap);
36 29
37 // These numbers come from java.lang.Runtime stats. 30 // These numbers come from java.lang.Runtime stats.
38 long total_heap_size = 0; 31 long total_heap_size = 0;
39 long free_heap_size = 0; 32 long free_heap_size = 0;
40 android::JavaRuntime::GetMemoryUsage(&total_heap_size, &free_heap_size); 33 android::JavaRuntime::GetMemoryUsage(&total_heap_size, &free_heap_size);
41 dump->set_physical_size_in_bytes(total_heap_size); 34 dump->AddScalar(MemoryAllocatorDump::kNameOuterSize,
42 dump->set_allocated_objects_count(0); 35 MemoryAllocatorDump::kUnitsBytes, total_heap_size);
43 dump->set_allocated_objects_size_in_bytes(total_heap_size - free_heap_size); 36 dump->AddScalar(MemoryAllocatorDump::kNameInnerSize,
37 MemoryAllocatorDump::kUnitsBytes,
38 total_heap_size - free_heap_size);
44 return true; 39 return true;
45 } 40 }
46 41
47 } // namespace trace_event 42 } // namespace trace_event
48 } // namespace base 43 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/malloc_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698