Skip to content

Commit 6c55582

Browse files
author
Ricardo Cervera
committed
docs: Describe the alloc tracker in Android Studio
Change-Id: Ic3cfc94950029104ec75ab04a9fac51ba64dd9a9
1 parent 7af4e81 commit 6c55582

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed
590 Bytes
Loading
684 Bytes
Loading
48.5 KB
Loading

docs/html/sdk/installing/studio-debug.jd

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ page.title=Debugging with Android Studio
1919
<li><a href="#breakPointsDebug">Debug your app with breakpoints</a></li>
2020
</ol>
2121
</li>
22+
<li><a href="#allocTracker">Track Object Allocation</a></li>
2223
<li><a href="#deviceMonitor">Analyze Runtime Metrics to Optimize your App</a></li>
2324
<li><a href="#screenCap">Capture Screenshots and Videos</a></li>
2425
</ol>
@@ -281,6 +282,47 @@ step:</p>
281282
<p class="img-caption"><strong>Figure 7.</strong> The Variables view in the Debug tool window.</p>
282283

283284

285+
<h2 id="allocTracker">Track Object Allocation</h2>
286+
287+
<p>Android Studio lets you track objects that are being allocated on the Java heap and see which
288+
classes and threads are allocating these objects. This allows you to see the list of objects
289+
allocated during a period of interest. This information is valuable for assessing memory usage
290+
that can affect application performance.</p>
291+
292+
<p>To track memory allocation of objects:</p>
293+
294+
<ol>
295+
<li>Start your app as described in <a href="#runDebug">Run Your App in Debug Mode</a>.</li>
296+
<li>Click <strong>Android</strong> <img src="{@docRoot}images/tools/as-android.png" alt=""
297+
style="vertical-align:bottom;margin:0;height:20px"/> to open the <em>Android DDMS</em>
298+
tool window.</li>
299+
<li>On the <em>Android DDMS</em> tool window, select the <strong>Devices | logcat tab</strong>.</li>
300+
<li>Select your device from the dropdown list.</li>
301+
<li>Select your app by its package name from the list of running apps.</li>
302+
<li>Click <strong>Start Allocation Tracking</strong>
303+
<img src="{@docRoot}images/tools/as-allocstart.png" alt=""
304+
style="vertical-align:bottom;margin:0;height:20px"/></li>
305+
<li>Interact with your app on the device.</li>
306+
<li>Click <strong>Stop Allocation Tracking</strong>
307+
<img src="{@docRoot}images/tools/as-allocstop.png" alt=""
308+
style="vertical-align:bottom;margin:0;height:20px"/></li>
309+
</ol>
310+
311+
<p>Android Studio shows the objects that the system allocated with the following information:</p>
312+
313+
<ul>
314+
<li>Allocation order</li>
315+
<li>Allocated class</li>
316+
<li>Allocation size</li>
317+
<li>Thread ID</li>
318+
<li>Allocation method, class, and line number</li>
319+
<li>Stack trace at the point of allocation</li>
320+
</ul>
321+
322+
<img src="{@docRoot}images/tools/as-alloctrack.png" alt="" width="750" height="252" />
323+
<p class="img-caption"><strong>Figure 8.</strong> Object allocation tracking in Android Studio.</p>
324+
325+
284326
<h2 id="deviceMonitor">Analyze Runtime Metrics to Optimize your App</h2>
285327

286328
<p>Even if your application does not generate runtime errors, this does not mean it is free of

0 commit comments

Comments
 (0)