Merge "docs: new Android Monitor doc b/24142260" into mnc-docs

This commit is contained in:
Cheryl Potter
2015-12-19 00:07:42 +00:00
committed by Android (Google) Code Review
48 changed files with 2530 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -0,0 +1,325 @@
page.title=CPU Monitor
parent.title=Android Monitor
parent.link=android-monitor.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#running">Displaying a Running App in the CPU Monitor</a></li>
<li><a href="#trace">Performing a Method Trace in the CPU Monitor</a></li>
<li><a href="#viewtrace">Viewing a Saved Method Trace</a></li>
<li><a href="#sorttrace">Sorting Method Trace Data</a></li>
<li><a href="#renametrace">Renaming a Method Trace File</a></li>
<li><a href="#locatetrace">Locating a Method Trace File on Disk</a></li>
<li><a href="#deletetrace">Deleting a Method Trace File</a></li>
</ol>
<h2>See also</h2>
<ol>
<li>
<a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>Make sure your development computer detects your hardware device, which often happens
automatically when you connect it to a USB port.
</li>
<li>
<a href="{@docRoot}tools/device.html#device-developer-options">Enable</a> <strong><a href=
"{@docRoot}tools/device.html#device-developer-options">USB debugging</a></strong> in
<strong>Developer Options</strong> on the device or emulator.
</li>
<li>In your app, set the <code>debuggable</code> property to <code>true</code> in the manifest or
<code>build.gradle</code> file (it’s initially set by default).
</li>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
The CPU Monitor lets you easily monitor the central processing unit (CPU) usage of your app. It
displays CPU usage in real time and displays the percentage of total CPU time (including all cores)
used by user and kernel mode. In user mode, the code must use system APIs to access hardware or
memory, and crashes are usually recoverable. In kernel mode, the code can directly access
hardware, including memory addresses; crashes halt the device.
</p>
<h2 id="running">
Displaying a Running App in the CPU Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Optionally connect a hardware device.
</li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>.
</li>
<li>Click the <strong>CPU</strong> tab.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run it</a> on a hardware device or
emulator.
</li>
<li>Enable the CPU Monitor by clicking Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> to deselect
it.
</li>
<p>
The CPU Monitor starts to display any CPU usage.
In the graph, the y-axis displays the percentage of CPU used. The x-axis records the time elapsed
and starts with seconds, and then minutes and seconds, and so on.
</p>
<img src="{@docRoot}images/tools/am-cpumon.png" style="vertical-align:sub;margin:0;width:450px" />
<li>To stop the CPU Monitor, click Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> again to select
it.
</li>
</ol>
<h2 id="trace">
Performing a Method Trace in the CPU Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>
<a href="{@docRoot}tools/help/android-monitor.html#displaying">Display a running app in the CPU
Monitor</a>.
</li>
<li>Start a trace by clicking Start Method Tracing <img src="{@docRoot}images/tools/am-imethodtrace.png"
style="vertical-align:sub;margin:0;height:17px" alt="Start Method Tracing icon" /> to
select it.
</li>
<li>To stop the trace, click Stop Method Tracing <img src="{@docRoot}images/tools/am-imethodtrace.png"
style="vertical-align:sub;margin:0;height:17px" alt="Stop Method Tracing icon" /> to
deselect it.
</li>
<p>
The method trace appears in the Code Editor area:
</p>
<img src="{@docRoot}images/tools/am-methodtrace.png" alt="Method Trace" />
<p>
Android Studio creates the method trace file
with the filename <code>Trace_<em>yyyy.mm.dd_hh.mm.ss</em>.trace</code>
using the year, month, day, hour, minute, and second of the capture, for example,
<code>Trace_2015.11.17_14.58.48.trace</code>.
</p>
<li>Specify display options:
<ul>
<li>Select a <strong>Thread</strong>.
</li>
<li>Select an <strong>x-axis</strong> time for the graphic and the method list:
</li>
<ul>
<li>
<strong>Wall Clock Time</strong> - Total CPU time elapsed between the method call and
return.
</li>
<li>
<strong>Thread Time</strong> - Total time during which the JRE scheduled the
thread during call processing. It’s less than or equal to the Wall Clock Time: less if
the JRE interrupted the thread, and equal if it didn’t.
The thread might not run continuously; when it’s not executing, that time is excluded.
If threads are interrupted often and it’s not by design, the interruptions affect app
performance. However, an example of a by-design use is synchronous operations that take
a long time, such as file transfers and reads from disk, where the method could be the
asynchronous wrapper for the synchronous reader.
</li>
</ul>
<li>
Optionally select <strong>Color by inclusive time</strong>.
</li>
</ul>
<p>
The display shows the following information:
</p>
<table>
<tr>
<th scope="col">Field</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><strong>Name</strong></td>
<td>The name of the method.</td>
</tr>
<tr>
<td><strong>Invocation Count</strong></td>
<td>How many times the method was called.</td>
</tr>
<tr>
<td><strong>Inclusive Time (microseconds)</strong></td>
<td>Time spent in the method and all of its children, either wall clock or thread time,
depending on your selection in the <strong>x-axis</strong> menu.</td>
</tr>
<tr>
<td><strong>Exclusive Time (microseconds)</strong></td>
<td>Time spent just in the method (excluding time spent in its children), either wall clock
or thread time, depending on your selection in the <strong>x-axis</strong> menu.</td>
</tr>
</table>
<p class="note"><strong>Note:</strong> Running the method trace significantly affects CPU timings.
Use the method trace to understand the flow of the program, but not for performance timings.</p>
<p>
The graphic represents the wall clock or thread time for each method. Hover the cursor
over the display to receive information about the method. This information also appears
in the table.
</p>
</ol>
<h2 id="viewtrace">
Viewing a Saved Method Trace
</h2>
<p>
After you do a method trace, Android Studio automatically stores it so you can view it
again. To examine the trace, follow these steps:
</p>
<ol>
<li>Click <strong>Captures</strong> in the main window.
</li>
<p>
The <em>Captures</em> window appears.
</p>
<li>Open the <strong>Methods Tracing</strong> folder.
</li>
<li>Double-click the file to view it.
</li>
</ol>
<h2 id="sorttrace">
Sorting Method Trace Data
</h2>
<p>
You can sort the data by method name, count, inclusive time, and exclusive time. Follow this step:
</p>
<ul>
<li>Click a column heading to sort the table by ascending or descending order.
</li>
</ul>
<h2 id="renametrace">
Renaming a Method Trace File
</h2>
<p>
Rename a method trace file from within Android Studio so it
continues to appear in the <em>Captures</em> window. Follow these steps:
</p>
<ol>
<li>In the <em>Captures</em> window, right-click the file and select <strong>Rename</strong>.
</li>
<li>In the dialog, specify the name of the file and click <strong>OK</strong>.
</li>
</ol>
<h2 id="locatetrace">
Locating a Method Trace File on Disk
</h2>
<p>
You can quickly discover where Android Studio stored method trace files on disk. Follow this step:
</p>
<ul>
<li>In the <em>Captures</em> window, right-click a method trace file and select <strong>Show in
files</strong>.
</li>
<p>
Android Studio opens an operating system file browser displaying the location where the file
resides.
</p>
</ul>
<p class="note">
<strong>Note:</strong> If you move a method trace file, Android Studio no longer displays the file
in the <em>Captures</em> window. To display it, use <strong>File</strong> &gt;
<strong>Open</strong>. Also, rename a file from the <em>Captures</em>
window and not in the operating system file browser.
</p>
<h2 id="deletetrace">
Deleting a Method Trace File
</h2>
<p>
Follow this step in Android Studio:
</p>
<ul>
<li>In the <em>Captures</em> window, right-click a method trace file and select
<strong>Delete</strong>.
</li>
</ul>
<p>
Android Studio deletes the file from the <em>Captures</em> dialog and from disk.
</p>

View File

@@ -0,0 +1,136 @@
page.title=GPU Monitor
parent.title=Android Monitor
parent.link=android-monitor.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#running">Displaying a Running App in the GPU Monitor</a></li>
</ol>
<h2>See also</h2>
<ol>
<li>
<a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>Make sure your development computer detects your hardware device, which often happens
automatically when you connect it to a USB port.
</li>
<li>
<a href="{@docRoot}tools/device.html#device-developer-options">Enable</a> <strong><a href=
"{@docRoot}tools/device.html#device-developer-options">USB debugging</a></strong> in
<strong>Developer Options</strong> on the device or emulator.
</li>
<li>For Android 5.0 (API level 21) and Android 5.1 (API level 22), in <strong>Developer
Options</strong> on the device or emulator, set <strong>Profile GPU rendering</strong> to
<strong>In adb shell dumpsys gfxinfo</strong>.
</li>
<li>In your app, set the <code>debuggable</code> property to <code>true</code> in the manifest or
<code>build.gradle</code> file (it’s initially set by default).
</li>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
The GPU Monitor gives you a quick visual representation of how much time it takes to render the
frames of a UI window. It profiles the amount of time it takes for the render thread to prepare,
process, and execute the draw commands. The GPU Monitor can help you to:
</p>
<ul>
<li>Quickly see how a UI window performs.
</li>
<li>Identify whether any part of the rendering pipeline stands out in using processing time.
</li>
<li>Look for spikes in frame rendering time associated with user or program actions.
</li>
</ul>
<p>
For example, if displaying a static photo continues to take Graphics Processor Unit
(GPU) resources long after it has finished
drawing on the screen, that’s a likely candidate for optimization.
</p>
<h2 id="running">
Displaying a Running App in the GPU Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Optionally connect a hardware device.
</li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>.
</li>
<li>Click the <strong>GPU</strong> tab.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run it</a> on a hardware device or
emulator.
</li>
<li>Enable the GPU Monitor by clicking Pause <img src="{@docRoot}images/tools/am-ipause.png" style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> to deselect
it.
</li>
<p>
Any GPU usage begins to appear in the GPU Monitor:
</p>
<img src="{@docRoot}images/tools/am-gpumon.png" style="vertical-align:sub;margin:0;width:450px" />
<p>
The y-axis is the amount of time it takes the GPU to execute, process, prepare, and draw frames,
in milliseconds. The x-axis records the time elapsed; it starts with seconds, and then minutes
and seconds, and so on.
</p>
<li>To stop the GPU Monitor, click Pause <img src="{@docRoot}images/tools/am-ipause.png" style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> again to select
it.
</li>
</ol>

View File

@@ -0,0 +1,521 @@
page.title=logcat Monitor
parent.title=Android Monitor
parent.link=android-monitor.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>
In this document
</h2>
<ol>
<li>
<a href="#format">logcat Message Format</a>
</li>
<li>
<a href="#running">Displaying a Running App in the logcat Monitor</a>
</li>
<li>
<a href="#level">Setting the Log Level</a>
</li>
<li>
<a href="#searching">Searching logcat Messages</a>
</li>
<li>
<a href="#filtering">Filtering logcat Messages</a>
</li>
<li>
<a href="#logheader">Configuring the logcat Header Display</a>
</li>
<li>
<a href="#stack">Moving Up and Down the Stack Trace</a>
</li>
<li>
<a href="#logend">Moving to the End of the Log</a>
</li>
<li>
<a href="#printing">Printing the Log</a>
</li>
<li>
<a href="#clearing">Clearing the Log</a>
</li>
<li>
<a href="#restarting">Restarting the Log</a>
</li>
</ol>
<h2>
See also
</h2>
<ol>
<li>
<a href="{@docRoot}tools/debugging/debugging-log.html">Reading and Writing Logs</a>
</li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
The Android logging system provides a mechanism for collecting and viewing system debug output.
logcat Monitor displays messages that you added to your app by using the <a href=
"{@docRoot}reference/android/util/Log.html">Log</a> class, as well as system
messages, such as stack traces when the emulator throws an error or a garbage collection occurs.
The monitor displays messages in real time and also keeps a history so you can view older
messages.
</p>
<p>
To display just the information of interest, you can create filters, modify how much information
is displayed in messages, set priority levels, display messages produced by app code
only, and search the log. By default, logcat Monitor shows the log output related to the running
application only.
</p>
<p>
You can traverse the stack trace when your app throws an exception, as well as view the
associated code. This feature can help you fix exceptions and improve app operation.
</p>
<h2 id="format">
logcat Message Format
</h2>
<p>
Every Android log message has a tag and a priority associated with it. The tag of a system
log message
is a short string indicating the system component from which the message originates (for example,
<code>ActivityManager</code>). A user-defined tag can be any string that you find helpful, such
as the name of the current class (the recommended tag). You define it in a <code>Log</code>
method call, for example:
</p>
<pre>
Log.d(tag, message);
</pre>
<p>
The priority is one of the following values:
</p>
<ul>
<li>
<strong>V</strong> — Verbose (lowest priority)
</li>
<li>
<strong>D</strong> — Debug
</li>
<li>
<strong>I</strong> — Info
</li>
<li>
<strong>W</strong> — Warning
</li>
<li>
<strong>E</strong> — Error
</li>
<li>
<strong>A</strong> — Assert
</li>
</ul>
<p>
The log message format is:
</p>
<pre class="no-pretty-print">
<em>date time PID-TID/package priority/tag: message</em>
</pre>
<p>
For example, the following log message has a priority of <code>V</code> and a tag of
<code>AuthZen</code>:
</p>
<pre class="no-pretty-print">
12-10 13:02:50.071 1901-4229/com.google.android.gms V/AuthZen: Handling delegate intent.
</pre>
<p>
PID stands for process identifier and TID is thread identifier; they can be the same if there’s
only one thread.
</p>
<h2 id="running">
Displaying a Running App in the logcat Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Optionally connect a hardware device.
</li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>.
</li>
<li>Click the <strong>logcat</strong> tab.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run it</a> on a hardware device or
emulator.
</li>
<p>
By default, the logcat Monitor displays messages for the app running on the device or emulator:
</p>
<img src="{@docRoot}images/tools/am-logcatmon.png" />
<p>
To change this default, see <a href="#filtering">Filtering logcat Messages</a>.
</p>
</ol>
<h2 id="level">
Setting the Log Level
</h2>
<p>
You can control how many messages appear in logcat Monitor by setting the log level. You can
display all messages, or just the messages indicating the most severe conditions.
</p>
<p>
Remember that logcat Monitor continues to collect all messages regardless of the log level setting.
The setting just determines what logcat Monitor displays.
</p>
<p>
Follow this step:
</p>
<ul>
<li>In the <strong>Log level</strong> menu, select one of the following values:
</li>
<ul>
<li>
<strong>Verbose</strong> - Show all log messages (the default).
</li>
<li>
<strong>Debug</strong> - Show debug log messages that are useful during development only,
as well as the message levels lower in this list.
</li>
<li>
<strong>Info</strong> - Show expected log messages for regular usage, as well as the
message levels lower in this list.
</li>
<li>
<strong>Warn</strong> - Show possible issues that are not yet errors, as well as the
message levels lower in this list.
</li>
<li>
<strong>Error</strong> - Show issues that have caused errors, as well as the message levels
lower in this list.
</li>
<li>
<strong>Assert</strong> - Show issues that the developer expects should never happen.
</li>
</ul>
</ul>
<h2 id="searching">
Searching logcat Messages
</h2>
<p>
You can search the messages currently displayed in logcat Monitor. Follow these steps:
</p>
<ol>
<li>Optionally select <strong>Regex</strong> if you want to use a regular expression
search pattern.
</li>
<li>Type a character sequence in the search field <img src="{@docRoot}images/tools/am-isearch.png"
style="vertical-align:sub;margin:0;height:17px" alt="Search icon" />.
</li>
<p>
The logcat Monitor display changes accordingly.
</p>
</li>
<li>Press <strong>Enter</strong> to store the sequence in the menu during this session.
</li>
<li>To repeat a search, choose it from the search menu. Select or deselect
<strong>Regex</strong> as needed (the setting isn’t remembered).
</li>
</ol>
<h2 id="filtering">
Filtering logcat Messages
</h2>
<p>
One way to reduce the log output to a manageable level is to restrict it by using a filter.
</p>
<p class="note">
<strong>Note:</strong> The filter applies to your full logcat history, not just those messages
currently displayed in logcat Monitor. Make sure your other display options are set
appropriately so you can see the filter output you want to examine.
</p>
<p>
To define and apply a filter, follow these steps:
</p>
<ol>
<li>In the filter menu, select a filter option:
<ul>
<li>
<strong>Show only selected application</strong> - Display the messages produced by the
app code only.
</li>
<li>
<strong>No Filters</strong> - Apply no filters (the default).
</li>
<li>
<strong>Edit Filter Configuration</strong> - Create or modify a custom filter.
</li>
</ul>
<p>
After you define filters, you can also select them in the menu. To remove them from the
menu, delete them.
</p>
<li>If you selected <strong>Edit Filter Configuration</strong>, create or modify a
filter.
<ol type="a">
<li>Specify the filter parameters in the <em>Create New Logcat Filter</em> dialog:
</li>
<ul>
<li>
<strong>Filter Name</strong> - Type the name of a filter you want to define, or
select it in the left pane to modify an existing filter. The name can contain
lowercase characters, underscores, and digits only.
</li>
<li>
<strong>Log Tag</strong> - Optionally specify a tag. For more information, see
<a href="#format">logcat Message Format</a>.
</li>
<li>
<strong>Log Message</strong> - Optionally specify log message text. For more
information, see <a href="#format">logcat Message Format</a>.
</li>
<li>
<strong>Package Name</strong> - Optionally specify a package name. For more
information, see <a href="#format">logcat Message Format</a>.
</li>
<li>
<strong>PID</strong> - Optionally specify a process ID. For more information, see
<a href="#format">logcat Message Format</a>.
</li>
<li>
<strong>Log Level</strong> - Optionally select a log level. For more information,
see <a href="#level">Setting the Log Level</a>.
</li>
<li>
<strong>Regex</strong> - Select this option to use regular expression syntax for
that parameter.
</li>
</ul>
<li>
Click <strong>+</strong> to add it to the left pane.
</li>
<p>
To remove a filter, select it in the left pane and click <strong>-</strong>.
</p>
<li>
When you’re finished, click <strong>OK</strong>. If you click
<strong>Cancel</strong>, any filter additions or modifications are lost.
</li>
</ol>
</ol>
<h2 id="logheader">
Configuring the logcat Header Display
</h2>
<p>
You can customize the header display to show just the information you’re interested
in:
</p>
<ul>
<li>Select Use Soft Wraps <img src="{@docRoot}images/tools/am-isoftwraps.png"
style="vertical-align:sub;margin:0;height:17px" alt="Use Soft Wraps icon" />
to see the entire
message and prevent it from running off of the right edge.
</li>
<li>Click Configure Logcat Header <img src="{@docRoot}images/tools/am-igear.png"
style="vertical-align:sub;margin:0;height:17px" alt="Configure Logcat header icon" />
to specify
elements of the messages that you want to show or hide, and then click
<strong>OK</strong>.
</li>
</ul>
<p>
For more information about message elements, see <a href=
"#format">logcat Message Format</a>.
</p>
<h2 id="stack">
Moving Up and Down the Stack Trace
</h2>
<p>
When the app throws an exception, the message includes a stack trace of method calls.
logcat
Monitor lets you quickly locate stack traces in the log and view the associated code
in the Code Editor. If needed (and possible), the decompiler derives source code that
you can view.
</p>
<ul>
<li>Click Up the Stack Trace <img src="{@docRoot}images/tools/am-iupstack.png"
style="vertical-align:sub;margin:0;height:17px" alt="Up the Stack Trace icon" />
to move to the
previous method in relation to the current position in the log.
</li>
<li>Click Down the Stack Trace <img src="{@docRoot}images/tools/am-idownstack.png"
style="vertical-align:sub;margin:0;height:17px" alt="Down the Stack Trace icon" />
to move to
the next method in relation to the current position in the log.
</li>
</ul>
<h2 id="logend">
Moving to the End of the Log
</h2>
<p>
Clicking a particular message stops the display of messages. You can quickly move to
the end of the log to see the real-time message flow.
</p>
<ul>
<li>Click Scroll to the End <img src="{@docRoot}images/tools/am-iscrollend.png"
style="vertical-align:sub;margin:0;height:17px" alt="Scroll to the End icon" />.
</li>
<li>Press the End key.
</li>
<li>Scroll or press the Page Down key until you reach the end.
</li>
</ul>
<h2 id="printing">
Printing the Log
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Click Print <img src="{@docRoot}images/tools/am-iprint.png"
style="vertical-align:sub;margin:0;height:17px" alt="Print icon" />.
</li>
<li>
In the <em>Print</em> dialog, optionally change print parameters, and then click
<strong>Print</strong>.
</ol>
<h2 id="clearing">
Clearing the Log
</h2>
<p>
To clear (flush) the entire log, follow this step:
</p>
<ul>
<li>Click Clear logcat <img src="{@docRoot}images/tools/am-iclear.png"
style="vertical-align:sub;margin:0;height:17px" alt="Clear logcat icon" />.
</li>
</ul>
<h2 id="restarting">
Restarting the Log
</h2>
<p>
If there is a problem and the log is no longer progressing, you can restart the log. Follow this
step:
</p>
<ul>
<li>Click Restart <img src="{@docRoot}images/tools/am-irestart.png"
style="vertical-align:sub;margin:0;height:17px" alt="Restart icon" />.
</li>
</ul>

View File

@@ -0,0 +1,916 @@
page.title=Memory Monitor
parent.title=Android Monitor
parent.link=android-monitor.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#workflow">Memory Monitor Workflow</a>
<ol>
<li><a href="#treeroot">Garbage collection roots and dominator trees</a></li>
<li><a href="#analysis">Memory leak and use analysis</a></li>
<li><a href="#vm">Memory management for different virtual machines</a></li>
</ol>
</li>
<li><a href="#displaying">Displaying a Running App in the Memory Monitor</a></li>
<li><a href="#forcing">Forcing a Garbage Collection Event</a></li>
<li><a href="#dumping">Dumping and Analyzing the Java Heap</a>
<ol>
<li><a href="#hprof-snapshot">Taking and displaying a snapshot of the Java heap</a></li>
<li><a href="#hprof-diving">Diving into heap dump data in the HPROF Viewer</a></li>
<li><a href="#hprof-analyzing">Analyzing heap dump data in the HPROF Analyzer</a></li>
<li><a href="#hprof-sorting">Sorting heap dump data</a></li>
<li><a href="#hprof-source">Displaying Java source</a></li>
<li><a href="#hprof-viewing">Viewing a saved HPROF file</a></li>
<li><a href="#hprof-renaming">Renaming an HPROF file</a></li>
<li><a href="#hprof-locating">Locating a heap dump file on disk</a></li>
<li><a href="#hprof-deleting">Deleting a heap dump file</a></li>
<li><a href="#hprof-converting">Converting a heap dump file to standard HPROF format</a></li>
</ol>
</li>
<li><a href="#tracking">Tracking and Analyzing Memory Allocation</a>
<ol>
<li><a href="#alloc-snapshot">Taking and displaying a snapshot of allocation data</a></li>
<li><a href="#alloc-sorting">Sorting allocation data</a></li>
<li><a href="#alloc-source">Displaying Java source</a></li>
<li><a href="#alloc-viewing">Viewing a saved allocation tracking file</a></li>
<li><a href="#alloc-renaming">Renaming an allocation tracking file</a></li>
<li><a href="#alloc-locating">Locating an allocation tracking file</a></li>
<li><a href="#alloc-deleting">Deleting an allocation tracking file</a></li>
</ol>
</li>
</ol>
<h2>See also</h2>
<ol>
<li><a href="{@docRoot}training/articles/memory.html">Managing Your App's Memory</a></li>
<li><a href="{@docRoot}guide/practices/verifying-apps-art.html#GC_Migration">Addressing Garbage Collection Issues</a></li>
<li><a href="{@docRoot}tools/debugging/debugging-memory.html">Investigating Your RAM Usage</a></li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>
Make sure your development computer detects your hardware device, which often happens
automatically when you connect it to a USB port.
</li>
<li>
<a href="{@docRoot}tools/device.html#device-developer-options">Enable</a> <strong><a href=
"{@docRoot}tools/device.html#device-developer-options">USB debugging</a></strong> in
<strong>Developer Options</strong> on the device or emulator.
</li>
<li>In your app, set the <code>debuggable</code> property to <code>true</code> in the manifest or
<code>build.gradle</code> file (it’s initially set by default).
</li>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
Android Studio provides a Memory Monitor so you can more easily monitor app performance and
memory usage to find deallocated objects, locate memory leaks, and track the amount of memory the
connected device is using. The Memory Monitor reports how your app allocates memory and helps you
to visualize the memory your app uses. It lets you:
</p>
<ul>
<li>Show a graph of available and allocated memory over time.
</li>
<li>Show garbage collection (GC) events
over time.
</li>
<li>Initiate garbage collection events.
</li>
<li>Quickly test whether app slowness might be related to excessive garbage collection events.
</li>
<li>Quickly test whether app crashes may be related to running out of memory.
</li>
</ul>
<h2 id="workflow">
Memory Monitor Workflow
</h2>
<p>
To profile and optimize memory use, the typical workflow is to run your app and do the following:
</p>
<ol>
<li>Profile the app using the Memory Monitor to find out whether undesirable garbage collection
event patterns might be causing performance problems.
</li>
<li>If you see many garbage collection events in a short amount of time, dump the Java heap to
identify candidate object types that get or stay allocated unexpectedly or unnecessarily.
</li>
<li>Start allocation tracking to determine where any problems are happening in your code.
</li>
</ol>
<p>
The Java heap data shows in real-time what types of objects your application has allocated, how
many, and their sizes on the heap. Viewing the heap helps you to:
</p>
<ul>
<li>Get a sense of how your app allocates and frees memory.
</li>
<li>Identify memory leaks.
</li>
</ul>
<p>
Allocation tracking records app memory allocations and lists all allocations for the
profiling cycle, including the call stack, size, and allocating code. It helps you to:
</p>
<ul>
<li>Identify where many similar object types, from roughly the same call stack, are allocated and
deallocated over a very short period of time.
</li>
<li>Find the places in your code that may contribute to inefficient memory use.
</li>
</ul>
<h3 id="treeroot">
Garbage collection roots and dominator trees
</h3>
<p>
When you dump the Java heap, the Memory Monitor creates an Android-specific Heap/CPU Profiling
(HPROF) file that you can view in the HPROF Viewer. The HPROF Viewer indicates a garbage
collection root with the <img src="{@docRoot}images/tools/am-igcroot.png"
style="vertical-align:sub;margin:0;height:17px" alt="GC Root icon" /> icon (and a depth of zero)
and a
dominator with the <img src="{@docRoot}images/tools/am-idom.png"
style="vertical-align:sub;margin:0;height:17px" alt="Dominator icon" /> icon.
</p>
<p>
There are several kinds of garbage collection roots in Java:
</p>
<ul>
<li>references on the stack</li>
<li>Java Native Interface (JNI) native objects and memory</li>
<li>static variables and functions</li>
<li>threads and objects that can be referenced </li>
<li>classes loaded by the bootstrap loader</li>
<li>finalizers and unfinalized objects</li>
<li>busy monitor objects</li>
</ul>
<p>
The HPROF file provides the list of roots to the HPROF Viewer.
</p>
<p>
A dominator tree traces paths to objects created by the app. An object dominates another object
if the only way to reach the other object is, directly or indirectly, through the dominator
object. When you examine objects and paths created by an app in an effort to optimize memory use,
try to remove objects that are no longer needed. You can release a dominator object to
release all subordinate objects. For example, in the following figure, if you were to
remove object B, that would also release the memory used by the objects it dominates, which are
objects C, D, E, and F. In fact, if objects C, D, E, and F were marked for removal, but object B
was still referring to them, that could be the reason that they weren’t released.
</p>
<img src="{@docRoot}images/tools/am-domtree.png" height="200" />
<h3 id="analysis">
Memory leak and use analysis
</h3>
<p>
An app performs better if it uses memory efficiently and releases the memory when it’s no longer
needed.
Memory leaks that are large or that grow over time are the most important to correct.
</p>
<p>
One way to optimize memory usage is to analyze large arrays. For example, can you reduce the size
of individual elements in the array to save memory? Does a dominator object point to
an element in the array, preventing it from being garbage-collected? If the dominator object
directly points to an element in the array, the dominator is either the contiguous memory
representing the underlying data of the array, some part of the array, or the array itself.
</p>
<p>
Another area that deserves attention is objects that the app no longer needs but continues to
reference. You can gather heap dumps over different periods of time and compare them to determine
if you have a growing memory leak, such as an object type that your code creates multiple times
but doesn’t destroy. These objects could be part of a growing array or an object tree, for
example. To track down this problem, compare the heap dumps and see if you have a particular
object type that continues to have more and more instances over time.
</p>
<p>
Continually growing object trees that contain root or dominator objects can prevent subordinate
objects from being garbage-collected. This issue is a common cause of memory leaks, out-of-memory
errors,
and crashes. Your app could have a small number of objects that are preventing a large number of
subordinate objects from being destroyed, so it runs out of memory quickly. To find these issues,
get a heap dump and examine the amount of memory held by root and dominator objects. If the
memory is substantial, you’ve likely found a good place to start optimizing your memory use.
</p>
<p>
As you start narrowing down memory issues, you should also use the Allocation Tracker to get a
better understanding of where your memory-hogging objects are allocated. The Allocation Tracker
can be valuable not only for looking at specific uses of memory, but also for analyzing critical
code paths, such as loading and scrolling. For example, tracking allocations when flinging a list
in your app
allows you to see all of the allocations that need to be done for that behavior, what thread they
are on, and where they came from. This information is extremely valuable for tightening up these
paths to reduce the work they need and improve the overall smoothness of the UI.
</p>
<p>
It’s useful to examine your algorithms for allocations that are unnecessary or that create the
same object many times instead of reusing them. For example, do you create temporary objects and
variables within recursive loops? If so, try creating an object or variable before
the loop for use within the loop. Otherwise, your app might needlessly allocate many objects and
variables, depending on the number of recursions.
</p>
<p>
It’s important to perform allocation tests on portions of your code that create the most and
largest objects, as those areas offer the most optimization opportunities. In addition to unit
tests, you should test your app with production-realistic data loads, especially those algorithms
that are data-driven. Also, make sure to account for the app caching and startup phase, which can
sometimes be slow; allocation analysis is best done after that phase to produce accurate results.
</p>
<p>
After you optimize code, be sure to test that it worked. You need to test under different load
conditions and also without running the Memory Monitor tools. Compare results before and after
optimization to make sure that performance has actually improved.
</p>
<h3 id="vm">
Memory management for different virtual machines
</h3>
<p>
Android Monitor uses the Virtual Machine (VM) that the device or emulator uses:
</p>
<ul>
<li>Android 4.3 (API level 18) and lower uses the Dalvik VM.
</li>
<li>In Android 4.4 (API level 19), the Android RunTime (ART) VM is an option, while the Dalvik VM
is the default.
</li>
<li>Android 5.0 (API level 21) and higher uses the ART VM.
</li>
</ul>
<p>
The VM handles garbage collection. The Dalvik VM uses a mark-and-sweep scheme for garbage
collection. The ART VM uses a generational scheme, combined with mark-and-sweep when memory needs
a more thorough garbage collection, such as when memory becomes excessively fragmented. The
logcat Monitor displays some messages that indicate the type of garbage collection that occurred
and why.
</p>
<p>
Memory Monitor results can vary between the different VMs. As a result, if you’re supporting both
VMs, you might want to test with both. In addition, the VMs available for different API levels
can have different behavior. For example, the Dalvik VM in Android 2.3 (API level 10) and lower
uses externally allocated memory while higher versions allocate in the Dalvik heap only.
</p>
<p>
You can’t reconfigure the Dalvik and ART VMs to tune performance. Instead, you should examine
your app code to determine how to improve its operation, for example, reducing the size of very
large arrays.
</p>
<p>
There are programmatic ways to manipulate when the VM performs garbage collection, although it’s
not a best practice. These techniques can be specific to the VM. For more information, see
<a href=
"{@docRoot}guide/practices/verifying-apps-art.html#GC_Migration">Addressing
Garbage Collection (GC) Issues</a> and <a href=
"{@docRoot}tools/debugging/debugging-memory.html">Investigating Your RAM
Usage</a>.
</p>
<p>
The ART VM adds a number of performance, development, and debugging improvements over the Dalvik
VM. For more information, see <a href=
"https://source.android.com/devices/tech/dalvik/index.html">ART and Dalvik</a>.
</p>
<h2 id="displaying">
Displaying a Running App in the Memory Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Optionally connect a hardware device.
</li>
<li>
<a href=
"{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>.
</li>
<li>Click the <strong>Memory</strong> tab.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run it</a> on a
hardware device or emulator.
</li>
<li>Enable the Memory Monitor by clicking Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> to deselect it.
</li>
<p>
In the graph, the y-axis displays the free and allocated RAM in megabytes. The x-axis shows the
time elapsed; it starts with seconds, and then minutes and seconds, and so on. The amount of free
memory, measured in megabytes,
is shown in a light color, and allocated memory is a darker color. When there’s a sharp drop in
allocated memory, that indicates a garbage collection event. </p>
<p>
To force a garbage collection event, click Initiate GC <img src="{@docRoot}images/tools/am-igc.png"
style="vertical-align:sub;margin:0;height:17px" alt="Initiate GC icon" />.
</p>
<p>In the following figure, the VM initiated the first garbage collection event, while the
developer forced the second.
</p>
<img src="{@docRoot}images/tools/am-gc.png" />
<li>Interact with your app and watch how it affects memory usage in the Memory Monitor. You can
identify garbage collection patterns for your app and determine whether they are healthy and what
you expect.
</li>
<p>
The graph can show you potential issues:
</p>
<ul>
<li>Excessive garbage collection events slow down the app.
</li>
<li>The app runs out of memory, which causes it to crash.
</li>
<li>Potential memory leaks.
</li>
</ul>
<p>
For example, you might see the following signs of problems:
</p>
<ul>
<li>Your app is static, but you see memory being allocated in the monitor.
</li>
<li>You see spikes of memory allocations in the monitor, but you don’t think there’s any app
logic to cause this behavior.
</li>
</ul>
<li>To stop the Memory Monitor, click Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> again to select it.
</li>
</ol>
<h2 id="forcing">
Forcing a Garbage Collection Event
</h2>
<p>
Normally, VMs perform garbage collection only when absolutely needed, since it’s expensive.
However, it can be useful to force garbage collection in certain circumstances. For example, when
locating memory leaks, if you want to determine whether a large object was successfully released
already, you can initiate garbage collection much more aggressively than usual.
</p>
<p>
To force a garbage collection event:
</p>
<ul>
<li>While the <a href="#displaying">Memory Monitor is running</a>, click Initiate GC
<img src="{@docRoot}images/tools/am-igc.png" style="vertical-align:sub;margin:0;height:17px"
alt="Initiate GC icon" />.
</li>
</ul>
<h2 id="dumping">
Dumping and Analyzing the Java Heap
</h2>
<p>
When you're monitoring memory usage in Android Studio you can, at the same time, dump the Java
heap to a heap snapshot in an Android-specific HPROF binary format file. The HPROF Viewer
displays classes, instances of each class, and a reference tree to help you track memory usage
and find memory leaks. HPROF is a heap dump format originally supported by J2SE.
</p>
<p>The Java heap display does the following:</p>
<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 is triggered by you.
</li>
<li>Helps identify which object types might be involved in memory leaks.
</li>
</ul>
<p>
However, you have to look for changes over time yourself by tracking what's happening in the
graph.
</p>
<p>
The HPROF Analyzer finds the following potential issues:
</p>
<ul>
<li>All destroyed activity instances that are reachable from garbage collection roots.
</li>
<li>Where the target program has strings that repeat values.
</li>
</ul>
<p>
A dominator is at the top of a tree. If you remove it, you also remove the branches of the tree
it dominates, so it’s a potential way to free memory.
</p>
<h3 id="hprof-snapshot">
Taking and displaying a snapshot of the Java heap
</h3>
<p>
To see a snapshot of the Java heap, follow these steps:
</p>
<ol>
<li>While the Memory Monitor is running, click Dump Java Heap
<img src="{@docRoot}images/tools/am-idump.png"
style="vertical-align:sub;margin:0;height:17px" alt="Dump Java Heap icon" />.
</li>
<p>
When the icon on the Memory Monitor display changes from
<img src="{@docRoot}images/tools/am-idumpstart.png"
style="vertical-align:sub;margin:0;height:17px" alt="Dump Java Heap Start icon" /> to
<img src="{@docRoot}images/tools/am-idumpend.png" style="vertical-align:sub;margin:0;height:17px"
alt="Dump Java Heap End icon" />, the file is ready. Android Studio creates the heap snapshot
file with the
filename <code>Snapshot_<em>yyyy.mm.dd_hh.mm.ss</em>.hprof</code> using
the year, month, day, hour, minute, and second of the capture, for example,
<code>Snapshot_2015.11.17_14.58.48.hprof</code>.
</p>
<li>Click <strong>Captures</strong> in the main window.
</li>
<p>
The <em>Captures</em> window appears.
</p>
<li>Double-click the file to view it in the HPROF Viewer.
</li>
<p>
The HPROF Viewer appears:
</p>
<img src="{@docRoot}images/tools/am-hprofviewer.png" />
<p>
The tool displays the following information:
</p>
<table>
<tr>
<th scope="col">Column</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><strong>Class Name</strong></td>
<td>The Java class responsible for the memory.</td>
</tr>
<tr>
<td><strong>Total Count</strong></td>
<td>Total number of instances outstanding.</td>
</tr>
<tr>
<td><strong>Heap Count</strong></td>
<td>Number of instances in the selected heap.</td>
</tr>
<tr>
<td><strong>Sizeof</strong></td>
<td>Size of the instances (currently, 0 if the size is variable).</td>
</tr>
<tr>
<td><strong>Shallow Size</strong></td>
<td>Total size of all instances in this heap.</td>
</tr>
<tr>
<td><strong>Retained Size</strong></td>
<td>Size of memory that all instances of this class is dominating.</td>
</tr>
<tr>
<td><strong>Instance</strong></td>
<td>A specific instance of the class.</td>
</tr>
<tr>
<td><strong>Reference Tree</strong></td>
<td>References that point to the selected instance, as well as references pointing to the
references.</td>
</tr>
<tr>
<td><strong>Depth</strong></td>
<td>The shortest number of hops from any GC root to the selected instance.</td>
</tr>
<tr>
<td><strong>Shallow Size</strong></td>
<td>Size of this instance.</td>
</tr>
<tr>
<td><strong>Dominating Size</strong></td>
<td>Size of memory that this instance is dominating.</td>
</tr>
</table>
<li>Select the Heap menu option you want to display:
<ul>
<li>
<strong>App heap</strong> - The heap used by the current app.
</li>
<li><strong>Image heap</strong> - The memory mapped copy of the
current app on disk.
</li>
<li>
<strong>Zygote heap</strong> - The common set of libraries and runtime classes and data that
all apps are forked
from. The zygote space is created during device startup and is never allocated into.
</li>
</ul>
<li>Select the View menu option you want to display:
<ul>
<li>
<strong>Class List View</strong>
</li>
<li>
<strong>Package Tree View</strong>
</li>
</ul>
</ol>
<h3 id="hprof-diving">
Diving into heap dump data in the HPROF Viewer
</h3>
<p>The following steps outline the typical workflow:</p>
<ol>
<li>In the HPROF viewer, select a class name. </li>
<li>Select an instance of that class.</li>
<li>Examine the reference tree.</li>
<li>Right-click an item to <strong>Jump to source</strong> or <strong>Go to instance</strong>,
as needed.</li>
</ol>
<h3 id="hprof-analyzing">Analyzing heap dump data in the HPROF Analyzer</h3>
<p>You can detect leaked activities and find duplicate strings with the HPROF Analyzer.
Follow these steps: </p>
<ol>
<li>In the <em>Captures</em> window, double-click an <code>.hprof</code> file to display it in the
HPROF Viewer. </li>
<li>Click <strong>Capture Analysis</strong> on the right side of the main Android Studio window.</li>
<p>The HPROF Analyzer appears to the right of the HPROF Analyzer, by default: </p>
<img src="{@docRoot}images/tools/am-hprofanalyzer.png" />
<li>In the <strong>Analyzer Tasks</strong> list, select the items you want to find.</li>
<li>Click Perform Analysis <img src="{@docRoot}images/tools/am-iperformanalysis.png"
style="vertical-align:sub;margin:0;height:17px" alt="Perform Analysis icon" />.</li>
<li>Examine the items in <strong>Analysis Results</strong>. Click an item to display it in the
HPROF Viewer.</li>
</ol>
<h3 id="hprof-sorting">Sorting heap dump data</h3>
<p>Follow this step:</p>
<ul>
<li>In the HPROF Viewer, click a column heading to sort the table by ascending or descending
order. </li>
</ul>
<h3 id="hprof-source">Displaying Java source</h3>
<p>For some items displayed in the HPROF Viewer, you can go straight to its source code.
Follow this step:</p>
<ul>
<li>In the HPROF Viewer, right-click a class, instance, or item in the reference tree, and then
select <strong>Jump to Source</strong>. </li>
<p>The source code appears in the Code Editor.</p>
</ul>
<h3 id="hprof-viewing">Viewing a saved HPROF file</h3>
<p>After you do a heap dump, Android Studio automatically stores it so you can view it again.
Follow these steps:</p>
<ol>
<li>Click <strong>Captures</strong> in the main window.</li>
<p>The <em>Captures</em> window appears.</p>
<li>Open the <strong>Heap Snapshot</strong> folder.</li>
<li>Double-click the file to view it.</li>
</ol>
<h3 id="hprof-renaming">Renaming an HPROF file</h3>
<p>If you rename a file from within Android Studio, it continues to appear in <em>Captures</em>
window. Follow these steps:</p>
<ol>
<li>In the <em>Captures</em> window, right-click the file and select <strong>Rename</strong>. </li>
<li>In the dialog, specify the name of the file and click <strong>OK</strong>.</li>
</ol>
<h3 id="hprof-locating">Locating a heap dump file on disk</h3>
<p>You can quickly discover where Android Studio stored HPROF files on disk.</p>
<p>Follow this step in Android Studio: </p>
<ul>
<li>In the <em>Captures</em> window, right-click a heap snapshot file and select
<strong>Show in files</strong>.</li>
<p>Android Studio opens an operating system file browser displaying the location where the file
resides.</p>
</ul>
<p class="note"><strong>Note:</strong> If you move an HPROF file, Android Studio no longer
displays it in the <em>Captures</em> window. To display it, use
<strong>File</strong> &gt; <strong>Open</strong>. Also, if you want to rename the file, do it
from the <em>Captures</em> window and not in the operating system file browser. </p>
<h3 id="hprof-deleting">Deleting a heap dump file</h3>
<p>To delete a heap dump file, follow this step: </p>
<ul>
<li>In the <em>Captures</em> window, right-click a heap snapshot file and select
<strong>Delete</strong>.</li>
<p>Android Studio deletes the file from the <em>Captures</em> dialog and from disk. </p>
</ul>
<h3 id="hprof-converting">Converting a heap dump file to standard HPROF format</h3>
<p>You can convert an HPROF file to standard format so you can use it outside of Android Studio with
other analysis tools. Follow these steps: </p>
<ol>
<li>In the <em>Captures</em> window, right-click a heap snapshot file and select <strong>Export to
standard .hprof</strong>.</li>
<li>In the <em>Convert Android Java Heap Dump</em> dialog, specify a filename and click
<strong>OK</strong>.</li>
<p>Android Studio creates a binary HPROF file in the location you specified.</p>
</ol>
<h2 id="tracking">
Tracking and Analyzing Memory Allocation
</h2>
<p>Android Studio allows you to track memory allocation as it monitors memory use. Tracking memory
allocation allows you to monitor where objects are being allocated when you perform certain
actions. Knowing these allocations enables you to adjust the method calls related to those actions
to optimize app performance and memory use.</p>
<p>The Allocation Tracker does the following:</p>
<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>Help you track down memory leaks when used in combination with the HPROF Viewer. For example,
if you see a bitmap object resident on the heap, you can find its allocation location with
Allocation Tracker.</li>
</ul>
<p>However, it takes time and experience to learn to interpret the output from this tool.</p>
<h3 id="alloc-snapshot">Taking and displaying a snapshot of allocation data</h3>
<p>Follow these steps:</p>
<ol>
<li>While the Memory Monitor is running, click Start Allocation Tracking
<img src="{@docRoot}images/tools/am-ialloctracking.png"
style="vertical-align:sub;margin:0;height:17px" alt="Start Allocation Tracking icon" />. </li>
<li>Click Start Allocation Tracking
<img src="{@docRoot}images/tools/am-ialloctracking.png"
style="vertical-align:sub;margin:0;height:17px" alt="Start Allocation Tracking icon" /> again to
deselect it and end the snapshot. </li>
<p>The Memory Monitor displays the period when it took the snapshot. In the following
figure, you can see the snapshot period, as shown on the left. By comparison, when you dump the
Java heap, the Memory Monitor displays just the point where the heap snapshot was taken, as
shown on the right.</p>
<img src="{@docRoot}images/tools/am-dumpalloc.png" />
<p>Android Studio creates the heap snapshot file with the
filename <code>Allocations_<em>yyyy.mm.dd_hh.mm.ss</em>.alloc</code> using the year, month, day,
hour, minute, and second of the capture, for example,
<code>Allocations_2015.11.17_14.58.48.alloc</code>.</p>
<li>Click <strong>Captures</strong> in the main window.</li>
<p>The <em>Captures</em> window appears.</p>
<li>Double-click the file to view it in the Allocation Tracker. </li>
<li>Optionally click the graphic icon to display a visual representation of the data.
</li>
<p>
The Allocation Tracker appears:
</p>
<img src="{@docRoot}images/tools/am-alloctracker.png" />
<p>
<p>The tool displays the following information: </p>
<table>
<tr>
<th scope="col">Column</th>
<th scope="col">Description</th>
</tr>
<tr>
<td><strong>Method</strong></td>
<td>The Java method responsible for the allocation.</td>
</tr>
<tr>
<td><strong>Count</strong></td>
<td>Total number of instances allocated.</td>
</tr>
<tr>
<td><strong>Size</strong></td>
<td>The total amount of allocated memory in bytes.</td>
</tr>
</table>
<li>Select the Group By menu option you want to display: </li>
<ul>
<li><strong>Group by Allocator</strong> </li>
<li><strong>Group by Method</strong></li>
</ul>
</ol>
<h3 id="alloc-sorting">Sorting allocation data</h3>
<p>Follow this step:</p>
<ul>
<li>In the Allocation Tracker, click a column heading to sort the table by ascending or
descending order. </li>
</ul>
<h3 id="alloc-source">Displaying Java source</h3>
<p>For some items displayed in the Allocation Tracker, you can view the Java source. Follow one of
these steps:</p>
<ul>
<li>In the Allocation Tracker, right-click a method and then select <strong>Jump to Source</strong>.
</li>
<li>In the Allocation Tracker, select a method and then click Jump to Source
<img src="{@docRoot}images/tools/am-ijumptosource.png"
style="vertical-align:sub;margin:0;height:17px" alt="Jump to Source icon" />. </li>
</ul>
<p>The source code appears in the Code Editor.</p>
<h3 id="alloc-viewing">Viewing a saved allocation tracking file</h3>
<p>After you monitor allocation tracking, Android Studio automatically stores it so you can view it
again. Follow these steps:</p>
<ol>
<li>Click <strong>Captures</strong> in the main window.</li>
<p>The <em>Captures</em> window appears.</p>
<li>Open the <strong>Allocation Tracking</strong> folder.</li>
<li>Double-click the file to view it.</li>
</ol>
<h3 id="alloc-renaming">Renaming an allocation tracking file</h3>
<p>If you rename a file from within Android Studio, it continues to appear in the <em>Captures</em>
window. Follow these steps:</p>
<ol>
<li>In the <em>Captures</em> window, right-click the file and select <strong>Rename</strong>.</li>
<li>In the <em>Rename</em> dialog, specify the name of the file and click <strong>OK</strong>.</li>
</ol>
<h3 id="alloc-locating">Locating an allocation tracking file</h3>
<p>You can quickly discover where Android Studio stored allocation tracking files on disk.</p>
<p>Follow this step in Android Studio: </p>
<ul>
<li>In the <em>Captures</em> window, right-click allocation file and select
<strong>Show in Files</strong>.</li>
<p>Android Studio opens an operating system file browser displaying the location where the file
resides.</p>
</ul>
<p class="note"><strong>Note:</strong> If you move an allocation tracking file, Android Studio
no longer displays it in the <em>Captures</em> window. To display the file, use
<strong>File</strong>
&gt; <strong>Open</strong>. Also, rename the file from the <em>Captures</em>
window and not in the operating system file browser. </p>
<h3 id="alloc-deleting">Deleting an allocation tracking file</h3>
<p>Follow this step: </p>
<ul>
<li>In the <em>Captures</em> window, right-click an allocation tracking file and select
<strong>Delete</strong>.</li>
<p>Android Studio deletes the file from the <em>Captures</em> dialog and from disk. </p>
</ul>

View File

@@ -0,0 +1,130 @@
page.title=Network Monitor
parent.title=Android Monitor
parent.link=android-monitor.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#running">Displaying a Running App in the Network Monitor</a></li>
</ol>
<h2>See also</h2>
<ol>
<li>
<a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
</ol>
<h2>Video</h2>
<ol>
<li><a href="https://www.youtube.com/watch?v=fEEulSk1kNY"
class="external-link">Battery Drain and Networking</a></li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>
<a href="{@docRoot}tools/building/building-studio.html#RunningOnDeviceStudio">Connect a
hardware device</a> to your development computer.
</li>
<li>Make sure your development computer detects your hardware device, which often happens
automatically when you connect it to a USB port.
</li>
<li>
<a href="{@docRoot}tools/device.html#device-developer-options">Enable</a> <strong><a href=
"{@docRoot}tools/device.html#device-developer-options">USB debugging</a></strong> in
<strong>Developer Options</strong> on the device.
</li>
<li>In your app, set the <code>debuggable</code> property to <code>true</code> in the manifest or
<code>build.gradle</code> file (it’s initially set by default).
</li>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
The Network Monitor makes it possible to track when your application is making network requests.
Using this tool, you can monitor how and when your app transfers data, and optimize the underlying
code appropriately.
</p>
<p>
By monitoring the frequency of data transfers, and the amount of data transferred during each
connection, you can identify areas of your app that can be made more efficient and use less
battery power.
Generally, you should look for short spikes that can be delayed, or that could cause a later
transfer to be preempted.
</p>
<h2 id="running">
Displaying a Running App in the Network Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Connect a hardware device.
</li>
<li>
<a href="{@docRoot}tools/help/android-monitor.html#displaying">Display Android Monitor</a>.
</li>
<li>Click the <strong>Network</strong> tab.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run it</a> on the hardware device.
</li>
<li>To start the Network Monitor, click Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> to
deselect it.
</li>
<p>
Any network traffic begins to appear in the Network Monitor:
</p>
<img src="{@docRoot}images/tools/am-networkmon.png" style="vertical-align:sub;margin:0;width:450px" />
<p>
The Network Monitor adds up the amount of time it takes for the device to transmit and receive
kilobytes of data.
The y-axis is in kilobytes per second. The x-axis starts with seconds, and then minutes and
seconds, and so on.
</p>
<li>To stop the Network Monitor, click Pause <img src="{@docRoot}images/tools/am-ipause.png"
style="vertical-align:sub;margin:0;height:17px" alt="Pause icon" /> again to
select it.
</li>
</ol>

View File

@@ -0,0 +1,462 @@
page.title=Android Monitor
parent.title=Tools
parent.link=index.html
page.tags=monitor
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol>
<li><a href="#displaying">Displaying Android Monitor</a></li>
<li><a href="#profiling">Profiling a Running App in Android Monitor</a></li>
<li><a href="#switching">Switching between Devices and Apps</a></li>
<li><a href="#screencapture">Taking a Screen Capture of the Device</a></li>
<li><a href="#video">Recording a Video from the Screen</a></li>
<li><a href="#sysinfo">Examining System Information</a></li>
<li><a href="#terminating">Terminating the App</a></li>
<li><a href="#rearranging">Rearranging Android Monitor Windows</a></li>
<li><a href="#removing">Removing an App from a Device</a></li>
</ol>
<h2>See also</h2>
<ol>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ol>
<h2>
Dependencies and Prerequisites
</h2>
<ul>
<li>In your app, set the <code>debuggable</code> property to <code>true</code> in the manifest or
<code>build.gradle</code> file (it’s initially set by default).
</li>
<li>Enable ADB integration through <strong>Tools</strong> &gt; <strong>Android</strong> &gt;
<strong>Enable ADB Integration</strong>.
</li>
<li>Make sure your development computer detects your hardware device, which often happens
automatically when you connect it to a USB port.
</li>
<li>
<a href="{@docRoot}tools/device.html#device-developer-options">Enable</a> <strong><a href=
"{@docRoot}tools/device.html#device-developer-options">USB debugging</a></strong> in
<strong>Developer Options</strong> on the device or emulator.
</li>
<li>
<a href="{@docRoot}tools/help/monitor.html">Android Device Monitor</a> can’t be running.
</li>
</ul>
</div>
</div>
<p>
Android Monitor helps you to profile the performance of your apps so you can optimize, debug, and
improve them. It lets you monitor the following aspects of your apps from a hardware device or
the Android Studio emulator:
</p>
<ul>
<li>
<a href="{@docRoot}reference/android/util/Log.html">Log</a> messages, either
system- or user-defined
</li>
<li>Memory, CPU, and GPU usage
</li>
<li>Network traffic (hardware device only)
</li>
</ul>
<p>
Android Monitor contains the logcat, Memory, CPU, GPU, and Network Monitors that you can use
separately to examine these aspects of your apps.
</p>
<h2 id="displaying">
Displaying Android Monitor
</h2>
<p>
Android Monitor is integrated into the Android Studio main window:
</p>
<ul>
<li>To display Android Monitor, click <img src="{@docRoot}images/tools/am-icon.png"
style="vertical-align:sub;margin:0;height:17px" alt="Android Monitor icon" />, which by default
is at the bottom of the main window.
</li>
<li>To hide Android Monitor, click <img src="{@docRoot}images/tools/am-icon.png"
style="vertical-align:sub;margin:0;height:17px" alt="Android Monitor icon" /> again.
</li>
</ul>
<img src="{@docRoot}images/tools/am-androidmon.png" style="vertical-align:sub;margin:0;width:480px" />
<h2 id="profiling">
Profiling a Running App in Android Monitor
</h2>
<p>
Follow these steps:
</p>
<ol>
<li>Optionally connect a hardware device.
</li>
<li>
<a href="#displaying">Display Android Monitor</a>.
</li>
<li>Open an app project and <a href=
"{@docRoot}tools/building/building-studio.html#RunningApp">run the app</a> on a device or
emulator.
</li>
<li>Click the tab for the monitor you want to view and start the monitor, if needed:
<ul>
<li><a href="{@docRoot}tools/help/am-logcat.html">logcat Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-memory.html">Memory Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-cpu.html">CPU Monitor</a>
</li>
<li><a href="{@docRoot}tools/help/am-gpu.html">GPU Monitor</a>
</li>
<li>
<a href="{@docRoot}tools/help/am-network.html">Network Monitor</a>
</li>
</ul>
</ol>
<h2 id="switching">
Switching between Devices and Apps
</h2>
<p>
By default, Android Monitor displays data for your most recently run app. You can switch to
another device and app as needed. In addition to currently running apps, you can view
information about apps that are no longer running so you can continue to view any information
about them that you gathered previously.
</p>
<p>
At the top of the Android Monitor main window are two menus listing devices and processes. To
switch to another device, process, or both, follow these steps:
</p>
<ol>
<li>Select the device or emulator.
</li>
<p>
The Device menu lists the devices and emulators that are running or have run during your
current session. There are various status messages that can appear in the Device menu:
</p>
<ul>
<li>
<strong>DISCONNECTED</strong> - You closed an emulator or unplugged a device from the
computer.
</li>
<li>
<strong>UNAUTHORIZED</strong> - A device needs you to accept the incoming computer
connection. For example, if the connected device displays an <em>Allow USB Debugging</em>
dialog, click <strong>OK</strong> to allow the connection.
</li>
<li>
<strong>OFFLINE</strong> - Android Monitor can’t communicate with a device, even though it
has detected that device.
</li>
</ul>
<li>Select the process.
</li>
</ol>
<p>
The Process menu lists the processes that are running or have run during your current session. If
a process is no longer running, the menu displays a status of <strong>DEAD</strong>.
</p>
<h2 id="screencapture">
Taking a Screen Capture of the Device
</h2>
<p>
You can take a PNG screenshot of the display on a connected device or the emulator. You can use
the images for your marketing materials as well as for debugging, for example.
</p>
<p>
Follow these steps:
</p>
<ol>
<li>
<a href="{@docRoot}training/basics/firstapp/running-app.html">Run your
app</a> from within Android Studio.
</li>
<li>
<a href="#switching">Select the device and the process</a> in the Android Monitor
menus, if needed.
</li>
<li>Interact with the display on the device or emulator to stage the image you want.
</li>
<li>Click Screen Capture <img src="{@docRoot}images/tools/am-iscreencapture.png"
style="vertical-align:sub;margin:0;height:17px" alt="Screen Capture icon" /> in the
Android Monitor toolbar.
</li>
<p>The screenshot appears in a <em>Screenshot Editor</em> window.</p>
<li>Optionally change the image:
<ul>
<li>
<strong>Reload</strong> - Click to take a new screenshot.
</li>
<li>
<strong>Rotate</strong> - Click to rotate the image 90 degrees clockwise.
</li>
<li>
<strong>Frame Screenshot</strong> - Select this option and choose a device to add an image
of the device to the outside of the screenshot. Select <strong>Drop Shadow</strong>,
<strong>Screen Glare</strong>, or both to add these effects to your image.
</li>
<li>
<strong>Chessboard</strong> and <strong>Grid</strong> - Select an option to display these
behind your image.
</li>
<li>
<strong>Zoom In</strong>, <strong>Zoom Out</strong>, or <strong>Actual Size</strong> -
Click these options to get different perspectives of your image without changing the image
itself.
</li>
</ul>
</li>
<li>Click <strong>Save</strong> to save the image.
</li>
</ol>
<h2 id="video">
Recording a Video from the Screen
</h2>
<p>
Android Studio lets you record an MP4 video from your hardware device for a maximum of three
minutes. You can use the video for your marketing materials as well as for debugging, for
example.
</p>
<p>
Follow these steps:
</p>
<ol>
<li>
<a href="{@docRoot}training/basics/firstapp/running-app.html">Run your
app</a> from within Android Studio.
</li>
<li>
<a href="#switching">Select the device and the process</a> in the Android Monitor
menus, if needed.
</li>
<li>Interact with the display on the device or emulator to stage the start of the video.
</li>
<li>Click Screen Record <img src="{@docRoot}images/tools/am-ivideo.png" style="vertical-align:sub;margin:0;height:17px" alt="Screen Record icon" /> in the Android Monitor toolbar.
</li>
<p>The screenshot appears in a Screenshot Editor window.</p>
<li>In the <em>Screen Recorder Options</em> dialog, optionally change the recording options:
</li>
<ul>
<li>
<strong>Bit Rate</strong> - Type a bit rate. The default is 4 Mbps.
</li>
<li>
<strong>Resolution</strong> - Type a width and height value in pixels. The value must be a
multiple of 16. The default is the resolution of the device.
</li>
</ul>
<li>Click <strong>Start Recording</strong> to start the recording.
</li>
<li>Click <strong>Stop Recording</strong> to stop the recording.
</li>
<li>In the <em>Save As</em> dialog, save the MP4 file.
</li>
<li>In the <em>Screen Recorder</em> dialog, click one of the buttons to show the file location,
open the recording in a player, or to dismiss the dialog.
</li>
</ol>
<h2 id="sysinfo">
Examining System Information
</h2>
<p>
You can view <code>dumpsys</code> output from within Android Monitor. Follow these steps:
</p>
<ol>
<li>
<a href="{@docRoot}training/basics/firstapp/running-app.html">Run your
app</a> from within Android Studio.
</li>
<li>
<a href="#switching">Select the device and the process</a> in the Android Monitor
menus, if needed.
</li>
<li>Click System Information <img src="{@docRoot}images/tools/am-isysteminfo.png"
style="vertical-align:sub;margin:0;height:17px" alt="System Information icon" /> and then a
menu item in the Android Monitor
toolbar.
</li>
<p>
The menu items display different types of <code><a href=
"https://source.android.com/devices/tech/debug/dumpsys.html">dumpsys</a></code> output:
</p>
<ul>
<li>
<strong>Activity Manager State</strong> - <code>dumpsys activity</code>
</li>
<li>
<strong>Package Information</strong> - <code>dumpsys package</code>
</li>
<li>
<strong>Memory Usage</strong> - <code><a href=
"{@docRoot}tools/debugging/debugging-memory.html#ViewingAllocations">dumpsys
meminfo</a></code>
</li>
<li>
<strong>Memory Use Over Time</strong> - <code><a href=
"http://android-developers.blogspot.com/2014/01/process-stats-understanding-how-your.html">dumpsys
procstats</a></code>
</li>
<li>
<strong>Graphics State</strong> - <code><a href=
"{@docRoot}training/testing/performance.html">dumpsys gfxinfo</a></code>
</li>
</ul>
<p>
The information appears in an editable text file in the Code Editor.
</p>
</ol>
<h2 id="terminating">
Terminating the App
</h2>
<p>
If you want to stop an app you’ve run from Android Studio, follow these steps:
</p>
<ol>
<li>
<a href="#switching">Select the device and the process</a> in the Android Monitor
menus, if needed.
</li>
<li>Click Terminate Application <img src="{@docRoot}images/tools/am-iterminate.png"
style="vertical-align:sub;margin:0;height:17px" alt="Terminate App icon" />.
</li>
<p>
The process status changes to <strong>DEAD</strong> in the Processes menu. The emulator or device
continues to run, but the app closes. Any running monitors in Android Monitor stop.
</p>
</ol>
<h2 id="rearranging">
Rearranging Android Monitor Windows
</h2>
<p>
You can rearrange the Android Monitor windows for optimal viewing during your tests:
</p>
<ul>
<li>To reorder the monitors, move the tabs back and forth.
</li>
<li>To move a monitor to a standalone window, grab a tab and move it to a different location on
the screen. Or, select <img src="{@docRoot}images/tools/am-igear.png" style="vertical-align:sub;margin:0;height:17px" alt="Gear menu icon" /> &gt; <strong>Floating Mode</strong>.
</li>
<li>To dock a standalone window, grab it and move it to the Android Monitor area. Or, select
<img src="{@docRoot}images/tools/am-igear.png" style="vertical-align:sub;margin:0;height:17px"
alt="Gear menu icon"> &gt; <strong>Floating Mode</strong> to deselect it.
</li>
<li>To combine two monitor displays together, grab a tab and move it onto another monitor.
</li>
<li>To hide a monitor, click the <img src="{@docRoot}images/tools/am-ihide.png" style="vertical-align:sub;margin:0;height:17px" alt="Hide icon" /> icon. To make it reappear, click the icon of
the monitor on the far right of the row of tabs.
</li>
</ul>
<h2 id="removing">
Removing an App from a Device
</h2>
<p>
To remove an app from a device you use for development, use the normal uninstall procedure on the
device.
</p>
<p>
If you run a new version of an app from Android Studio that’s been already installed on a
hardware device, the device displays an <em>Application Installation Failed</em> dialog. Click
<strong>OK</strong> to install the new version of the app.
</p>

View File

@@ -68,6 +68,10 @@ avd</code>) the emulator (<code>emulator</code>), and the Dalvik Debug Monitor S
<h3 id="tools-debugging">Debugging Tools</h3>
<dl>
<dt><a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a></dt>
<dd>Android Monitor is integrated into Android Studio and provides logcat, memory, CPU, GPU, and
network monitors for app debugging and analysis.</dd>
<dt><a href="{@docRoot}tools/help/adb.html">adb</a></dt>
<dd>Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with
an emulator instance or connected Android-powered device. It also provides access to the

View File

@@ -3,15 +3,25 @@ parent.title=Tools
parent.link=index.html
@jd:body
<div id="qv-wrapper">
<div id="qv">
<h2>See also</h2>
<ol>
<li><a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a></li>
</ol>
</div>
</div>
<p>The Android logging system provides a mechanism for collecting and viewing system debug
output. Logs from various applications and portions of the system are collected in a series of
circular buffers, which then can be viewed and filtered by the <code>logcat</code> command. You can use
circular buffers, which then can be viewed and filtered by the <code>logcat</code> command. You can use
<code>logcat</code> from an ADB shell to view the log messages.</p>
<p>For complete information about logcat options and filtering specifications, see
<a href="{@docRoot}tools/debugging/debugging-log.html">Reading and Writing Logs</a>.</p>
<p>For more information on accessing <code>logcat</code> from DDMS, instead of the command line, see
<p>For more information on accessing <code>logcat</code> from DDMS, instead of the command line, see
<a href="{@docRoot}tools/debugging/ddms.html">Using DDMS</a>. </p>
<h3>Syntax</h3>
@@ -34,7 +44,7 @@ $ adb shell
<h3>Options</h3>
<p>The following table describes the command line options of <code>logcat</code>.</p>
<table>
<tr>
<th>Option</th>
@@ -46,7 +56,7 @@ $ adb shell
<td><code>-b&nbsp;&lt;buffer&gt;</code></td>
<td>Loads an alternate log buffer for viewing, such as <code>events</code> or
<code>radio</code>. The <code>main</code> buffer is used by default. See <a href=
<code>radio</code>. The <code>main</code> buffer is used by default. See <a href=
"{@docRoot}tools/debugging/debugging-log.html#alternativeBuffers">Viewing Alternative Log Buffers</a>.</td>
</tr>

View File

@@ -8,6 +8,7 @@ page.title=Device Monitor
<ol>
<li><a href="{@docRoot}tools/debugging/debugging-memory.html"
>Investigating Your RAM Usage</a></li>
<li><a href="{@docRoot}tools/help/android-monitor.html">Android Monitor</a></li>
</ol>
</div>
</div>

View File

@@ -168,6 +168,27 @@ class="en">Tools Help</span></a></div>
<ul>
<li><a href="<?cs var:toroot ?>tools/help/adb.html">adb</a></li>
<li><a href="<?cs var:toroot ?>tools/help/android.html">android</a></li>
<li class="nav-section">
<div class="nav-section-header">
<a href="<?cs var:toroot ?>tools/help/android-monitor.html">Android Monitor</a></div>
<ul>
<li><a href="<?cs var:toroot ?>tools/help/am-logcat.html"><span
class="en">logcat Monitor</span></a>
</li>
<li><a href="<?cs var:toroot ?>tools/help/am-memory.html"><span
class="en">Memory Monitor</span></a>
</li>
<li><a href="<?cs var:toroot ?>tools/help/am-cpu.html"><span
class="en">CPU Monitor</span></a>
</li>
<li><a href="<?cs var:toroot ?>tools/help/am-gpu.html"><span
class="en">GPU Monitor</span></a>
</li>
<li><a href="<?cs var:toroot ?>tools/help/am-network.html"><span
class="en">Network Monitor</span></a>
</li>
</ul>
</li>
<li><a href="<?cs var:toroot ?>tools/help/avd-manager.html">AVD Manager</a></li>
<li><a href="<?cs var:toroot ?>tools/help/bmgr.html">bmgr</a>
<li><a href="<?cs var:toroot ?>tools/help/monitor.html">Device Monitor</a></li>