Langsung ke konten

Paling sering dikunjungi

Terakhir dikunjungi

navigation

Allocation Tracker

This tool was removed in Android Studio 3.0.

You should get the latest version of Android Studio and use the new Memory Profiler instead.

Android Monitor 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.

The Allocation Tracker does the following:

However, it takes time and experience to learn to interpret the output from this tool.

Understanding the Allocation Tracker Display

The Allocation Tracker looks similar to the following figure:

The tool displays the following information:

Column Description
Method The Java method responsible for the allocation.
Count Total number of instances allocated.
Size The total amount of allocated memory in bytes.

Taking and Displaying a Snapshot of Allocation Data

To examine allocation data:

  1. Display a running app in the Memory Monitor.
  2. Click Start Allocation Tracking Start Allocation Tracking icon.
  3. Click Start Allocation Tracking Start Allocation Tracking icon again to deselect it and end the snapshot.
  4. 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.

    Android Studio creates the heap snapshot file with the filename package_yyyy.mm.dd_hh.mm.ss.alloc using the activity package (or project) name, year, month, day, hour, minute, and second of the capture, for example, com.android.calc_2015.11.17_14.58.48.alloc.

    The Allocation Tracker appears.

  5. Optionally click the graphic icon graphic icon to display a visual representation of the data.
  6. Select the Group By menu option you want to display:
    • Group by Allocator
    • Group by Method

Viewing a Saved Allocation Tracking File

After you capture allocation data, Android Studio automatically stores it so you can view it again.

To view an allocation tracking file in the Allocation Tracker:

  1. Click Captures icon in the main window.
  2. Or select View > Tools Windows > Captures.

    The Captures window appears.

  3. Open the Allocation Tracking folder.
  4. Double-click the file to view it.

Sorting Allocation Data

To sort allocation data:

Displaying Java Source

For some items displayed in the Allocation Tracker, you can view the Java source.

To display Java source:

The source code appears in the Code Editor.

Working with Allocation Tracking Files

You can rename, locate, and delete an allocation tracking file from within Android Studio.

Renaming an allocation tracking file

If you rename a file from within Android Studio, it continues to appear in the Captures window.

To rename an allocation tracking file:

  1. In the Captures window, right-click the file and select Rename.
  2. In the Rename dialog, specify the name of the file and click OK.

Locating an allocation tracking file

You can quickly discover where Android Studio stored allocation tracking files on disk.

To locate an allocation tracking file from Android Studio:

Note: If you move an allocation tracking file, Android Studio no longer displays it in the Captures window. To display the file, use File > Open. Also, rename the file from the Captures window and not in the operating system file browser.

Deleting an allocation tracking file

To delete an allocation tracking file:

Situs ini menggunakan cookies untuk menyimpan preferensi Anda tentang bahasa di situs tertentu dan opsi tampilan.

Dapatkan berita dan tips terbaru dari developer Android yang akan membantu Anda mencapai kesuksesan di Google Play.

* Wajib Diisi

Hore!

Ikuti Google Developers di WeChat

Buka situs ini dalam bahasa ?

Anda meminta halaman dalam bahasa , namun preferensi bahasa untuk situs ini adalah .

Ingin mengubah preferensi bahasa dan mengakses situs ini dalam bahasa ? Jika nanti Anda ingin mengubah preferensi bahasa, gunakan menu bahasa di bagian bawah setiap halaman.

Kelas ini memerlukan tingkat API atau yang lebih tinggi

Dokumen ini tersembunyi karena level API yang Anda pilih untuk dokumentasi ini adalah . Anda dapat mengubah level API dokumentasi dengan pemilih di atas menu navigasi sebelah kiri.

Untuk informasi lebih lanjut tentang menentukan level API yang diperlukan aplikasi Anda, baca Mendukung Versi Platform Yang Berbeda.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)