Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ How MAT Android application memory leak analysis     - Linux firewall to prevent external network attacks (Linux)

- RedHat Linux 6.4 install Oracle 10g error (Database)

- Linux Change ssh port and disable remote root login at (Linux)

- Resolve the host via KVM console can not connect clients (Linux)

- SSH without password Definitive Guide (Linux)

- Linux Task Scheduler (at, crontab) (Linux)

- U disk to install Windows and Ubuntu 15.04 dual system (Programming)

- Hibernate Search 5.5 in the search results sorted (Linux)

- Effect MongoDB plan cache (Database)

- Linux file system management partition, format, mount - label mount (Linux)

- linux server security (Linux)

- CentOS 6.5 installation Python3.0 (Linux)

- Eclipse improve the efficiency of good habits (Programming)

- Android basics summary article (Programming)

- Linux Getting Started tutorial: GNU C and Vim will fight the C / C ++ IDE semi-automatic (Linux)

- High-performance JavaScript DOM programming (Programming)

- Virtualization and IT cooperation (Linux)

- REDO LOG records management (Database)

- How to use the beta / unstable version of the software in Debian library (Linux)

- Oracle Linux 7.1 install Oracle 12C RAC (Database)

  How MAT Android application memory leak analysis
  Add Date : 2018-11-21      
  The use of tools: Android Studio 2.0 Preview, Android Device Monitor, MAT (Memory Analyzer).

Click on "Android Device Monitor" Android Studio toolbar

After opening the application process is selected, then click on the "Update heap", then click on each activity applied repeatedly, and finally "Dump HPROF file"

Save hprof file.

The following need to hprof file conversion.

Open CMD terminal, into the \ sdk \ platform-tools directory, use hprof-conv command to convert the file hprof

hprof-conv F: /a.hprof F: /b.hprof
Finally get b.hprof file.

To the official website: http: //www.eclipse.org/mat/downloads.php download Memory Analyzer tool.

Choose your version.

Open MemoryAnalyzer.exe, toolbar, select "File" -> "Open Heap Dump", select b.hprof

Overview selected in Action, click on the "Histogram"

You can search for the project name of the class, support partial match. I enter the Radar, a match the following content

Right One, select "Merge Shortest Paths to GC Roots" -> "exclude all phantom / weak / soft etc. references"

You can also use Overview The Dominator Tree to generate a new list, use Path again to GC Roots -> exclude weak / soft references screening procedures associated with memory leaks class.

Since ToastUtil is a utility class methods are static, and accept the Context parameter, this time passing in a activity in the Activity of context, leading to ToastUtil holds a reference to the activity while the activity is not released, the memory leak . The solution: a pass application context into account, let ToastUtil this context and have the same life cycle.

In addition, there will be Handler improper use of memory leaks, such as the use postDelayed in Handler.

Common solutions include the following:

1, the use of a static internal Handler / Runnable + weak references

2, onDestory when manually remove Message

3, third-party developers to use Badoo's WeakHandler
- Linux resource restriction level summary (Linux)
- Oracle Data File Management (Database)
- Linux Getting Started tutorial: 3D effects and beautify your desktop (Linux)
- Linux firewall settings -DNS server articles (Server)
- Configuring automatic mail GAMIT under CentOS system (Linux)
- Json Applications of FastJson (Programming)
- Minimum period string problem (Programming)
- Linux basic introductory tutorial ---- regex basis (Linux)
- Adjust the size of the hard disk VirtualBox (Linux)
- C language programming entry - Common operators (Programming)
- MYSQL root password for the database user passwords are weak attack analysis (Linux)
- 14.04.3 Ubuntu configuration and successfully compiled source code Android 6.0 r1 (Programming)
- 2016, the new Node project Precautions (Programming)
- Linux System Getting Started Tutorial: permission to permanently modify the USB device in Linux (Linux)
- Linux group account deletion, and other related operations (Linux)
- Redis Linux system installation guide (Database)
- Caffe install under Ubuntu 14.04 64bit (Linux)
- The Linux OOM Terminator (Server)
- To set up the printer use Nagios Monitoring Server (Server)
- Oracle EBS R12 for Linux installation (Database)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.