MAT using android development tools to detect memory leaks View

1. Download the MAT tool HTTPS: // www.eclipse.org/mat/downloads.php
2 . Right Open mat.app, open the MAT tool to open the can go wrong under the mac, the solution is as follows:
  Edit mat.app/Contents/Eclipse MemoryAnalyzer.ini file, and
  add the log output directory before --launcher.library
  -data
  / the Users / xx / log
  my modified as follows:
    
3 . use of Android Studio Profiler export the original file hprof
  
4 using android sdk comes. hprof-conv tool in platform-tools hprof converting the original document, the following command:
  hprof-conv .hprof ./ ./ original file object file .hprof
5. the mat tool to open a target file hprof
  right open mat.app opening tool mat, then open file button heap (open a heap Dump) clicks table (Workspace), select and open the target file.

6. Analysis of the target file hprof
   
   If the corresponding Objects column is greater than 1, it may be the emergence of contents leaked. Read on who is referenced memory leaks caused by:
    Step 4: Select and right -> List objects -> with incoming references cited examples of open view. 
    Step 5: In view of the reference example, continue to select and right -> Path To GC Roots -> with all references to see all references to the path.

Of course, most of the time are now automatically detect the use of open source projects, such as LeakCanary. LeakCanary project analysis and parsing hprof principle also dump file. It is also necessary to learn to use the MAT tool.

 

Guess you like

Origin www.cnblogs.com/yongfengnice/p/12061389.html