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