page.title=Memory Monitor Walkthrough
meta.tags="android, performance, profiling, tools, memory, memoryleaks, garbagecollection, memorymonitor"
page.tags="android", "performance", "profiling", "tools", "memory", "memoryleaks", "garbagecollection", "memorymonitor"
page.metaDescription=Graph memory usage and garbage collection events for your app in real-time.
page.image=tools/performance/thumbnails/tools_memory_monitor.png
page.article=true
@jd:body
In this document
You should also read
This walkthrough shows the basic usage and workflow for the Memory Monitor tool in Android
Studio. Memory Monitor reports in real-time how your app allocates memory.
What it's good for:
- Showing available and used memory in a graph, and garbage collection events over time.
- Quickly testing whether app slowness might be related
to excessive garbage collection events.
- Quickly testing whether app crashes may be related to running out of
memory.
Prerequisites
Working with Memory Monitor
- If you're using a mobile device, connect it to your computer.
- Open your application in Android Studio, build the source,
and run it on your device or emulator.
- In Android Studio, choose Tools > Android > Memory Monitor. You
can also click the Android tab in the lower-left corner of the application
window to launch the Android runtime window. The CPU and Memory Monitor views appear.
- Once Memory Monitor starts tracking your device, a stacked graph appears,
tracking memory usage over time.
Dark blue: Amount of memory that your app
is currently using.
Light blue: Available, unallocated memory.
- Over time, this graph updates, showing changes in memory usage.
- As your app allocates and frees memory, the allocated amount shown in the
graph changes.
- When you see the allocated memory drop by a large amount, a garbage
collection (GC) event has occurred.
- You can force a garbage collection event by clicking on the garbage truck
icon
.