1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
page.title=Memory Profilers
meta.tags="android, performance, profiling, tools, memory, memoryleaks, garbagecollection"
page.tags="android", "performance", "profiling", "tools", "memory", "memoryleaks", "garbagecollection"
page.metaDescription=Heap Viewer, Memory Monitor, and Allocation Tracker are complementary tools that visualize the memory your app uses.
page.image=tools/performance/thumbnails/tools_memory_monitor.png
page.article=true
@jd:body
<div id="tb" style="margin-left: 7px; margin-bottom: 5px;">
<h2>In this document</h2>
<ul>
<li><a href="#MemoryMonitor">Memory Monitor</a></li>
<li><a href="#HeapViewer">Heap Viewer</a></li>
<li><a href="#AllocationTracker">Allocation Tracker</a></li>
</ul>
<h2>You should also read</h2>
<ul>
<li><a href="{@docRoot}tools/performance/memory-monitor/index.html">
Memory Monitor Walkthrough</a></li>
<li><a href="{@docRoot}tools/performance/heap-viewer/index.html">
Heap Viewer Walkthrough</a></li>
<li><a href="{@docRoot}tools/performance/allocation-tracker/index.html">
Allocation Tracker Walkthrough</a></li>
</ul>
</div>
<p>Heap Viewer, Memory Monitor, and Allocation Tracker are complementary tools that visualize the
memory your app uses.</p>
<ol>
<li>Use the
<a href="{@docRoot}tools/performance/memory-monitor/index.html">
Memory Monitor Tool</a> to find out whether undesirable garbage collection (GC) event patterns might
be causing your performance problems.</li>
<li>Run
<a href="{@docRoot}tools/performance/heap-viewer/index.html">
Heap Viewer</a> to identify object types that get or stay allocated
unexpectedely or unecessarily.</li>
<li>Use
<a href="{@docRoot}tools/performance/allocation-tracker/index.html">
Allocation Tracker</a> to identify where in your code the problem might be.</li>
</ol>
<h2 id="MemoryMonitor">Memory Monitor</h2>
<div>
<div class="figure" style="">
<img src="{@docRoot}images/tools/performance/compare_MemoryMonitor.png"
alt=""
height="" />
<p class="img-caption">
<strong>Figure 1. </strong>Memory Monitor.
</p>
</div>
<ul>
<li>Shows available and used memory as they both change over time <i>for your app</i> in a
graph, with dips indicating Garbage Collection (GC) events.</li>
<li>Provides a quick way to test whether app slowness might be related
to excessive GC events.</li>
<li>Provides a quick way to see whether app crashes might be related
to running out of memory.</li>
<li>Runs live on your application and updates about once a second.</li>
<li>Helps quickly identify the potential of memory leaks.</li>
<li>Helps identify GC patterns for your application and determine whether
they are healthy and what you expect.</li>
<li>Is easy to use, and it is easy to interpret what you see.</li>
<li>However, Memory Monitor does not tell you which objects are the cause
of your problems, or where in your code it might be.</li>
</ul>
<h2 id="HeapViewer">Heap Viewer</h2>
<div class="figure" style="">
<img src="{@docRoot}images/tools/studio-hprof-viewer.png"
alt=""
height="" />
<p class="img-caption">
<strong>Figure 2. </strong>Heap Viewer.
</p>
</div>
<ul>
<li>Shows snapshots of a number of objects allocated by type.</li>
<li>Samples data every time a garbage collection event occurs
naturally or triggered by you.</li>
<li>Helps identify which object types might be involved in memory leaks.</li>
<li>However, you have to look for changes over time yourself by tracking what's
happening in the graph.</li>
<br><br><br><br>
</ul>
<h2 id="AllocationTracker">Allocation Tracker</h2>
<div class="figure" style="">
<img src="{@docRoot}images/tools/performance/compare_AllocationTracker.png"
alt=""ge
height="" />
<p class="img-caption">
<strong>Figure 3. </strong>Allocation Tracker.
</p>
</div>
<ul>
<li>Shows when and where your code allocates object types, their size, allocating thread, and
stack traces.</li>
<li>Helps recognize memory churn through recurring allocation/deallocation patterns.</li>
<li>Can be used in combination with Heap Viewer to track down memory leaks. For example, if you
see a bitmap object resident on the heap, you can find its allocation location with Allocation
Tracker.</li>
<li>However, it takes time and experience to learn to interpret the output from this tool.</li>
</ul>
|