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

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

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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 | « base/trace_event/BUILD.gn ('k') | base/trace_event/malloc_dump_provider.h » ('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 // static 13 // static
14 JavaHeapDumpProvider* JavaHeapDumpProvider::GetInstance() { 14 JavaHeapDumpProvider* JavaHeapDumpProvider::GetInstance() {
15 return Singleton<JavaHeapDumpProvider, 15 return Singleton<JavaHeapDumpProvider,
16 LeakySingletonTraits<JavaHeapDumpProvider>>::get(); 16 LeakySingletonTraits<JavaHeapDumpProvider>>::get();
17 } 17 }
18 18
19 JavaHeapDumpProvider::JavaHeapDumpProvider() { 19 JavaHeapDumpProvider::JavaHeapDumpProvider() {
20 } 20 }
21 21
22 JavaHeapDumpProvider::~JavaHeapDumpProvider() { 22 JavaHeapDumpProvider::~JavaHeapDumpProvider() {
23 } 23 }
24 24
25 // 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
26 // for the current process. 26 // for the current process.
27 bool JavaHeapDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) { 27 bool JavaHeapDumpProvider::OnMemoryDump(ProcessMemoryDump* pmd) {
28 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump("java_heap");
29
30 // These numbers come from java.lang.Runtime stats. 28 // These numbers come from java.lang.Runtime stats.
31 long total_heap_size = 0; 29 long total_heap_size = 0;
32 long free_heap_size = 0; 30 long free_heap_size = 0;
33 android::JavaRuntime::GetMemoryUsage(&total_heap_size, &free_heap_size); 31 android::JavaRuntime::GetMemoryUsage(&total_heap_size, &free_heap_size);
34 dump->AddScalar(MemoryAllocatorDump::kNameOuterSize, 32
35 MemoryAllocatorDump::kUnitsBytes, total_heap_size); 33 MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("java_heap");
36 dump->AddScalar(MemoryAllocatorDump::kNameInnerSize, 34 outer_dump->AddScalar(MemoryAllocatorDump::kNameSize,
37 MemoryAllocatorDump::kUnitsBytes, 35 MemoryAllocatorDump::kUnitsBytes, total_heap_size);
38 total_heap_size - free_heap_size); 36
37 MemoryAllocatorDump* inner_dump =
38 pmd->CreateAllocatorDump("java_heap/allocated_objects");
39 inner_dump->AddScalar(MemoryAllocatorDump::kNameSize,
40 MemoryAllocatorDump::kUnitsBytes,
41 total_heap_size - free_heap_size);
39 return true; 42 return true;
40 } 43 }
41 44
42 } // namespace trace_event 45 } // namespace trace_event
43 } // namespace base 46 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/BUILD.gn ('k') | base/trace_event/malloc_dump_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698