• HPROF学习


     抓取HPROF log

    1. GUI

    可以通过 adt-bundle-windows-x86_64-20140702sdk oolsmonitor.bat来抓取。

    打开软件,选中相应的包,比如“com.android.mms”,然后点击"Dump HPROF file" 按钮,保存为 “mms_0810.hprof" 即可。

    2.通过代码

    在编写代码的时候,如果想保存HPROF文件,使用android.os.Debug.dumpHprofData()函数即可。

       xxxButton.setOnClickListener(new View.OnClickListener() {
           public void onClick(View view) {
              android.os.Debug.dumpHprofData("/sdcard/com.android.mms.hprof");
           }
       }

    3.命令行

    adb shell am dumpheap com.android.mms /data/mms_0810.hprof

    关于dumpheap 的使用方法,可以参考下面。

    另外,查找一个JAVA使用的命令行工具。

    http://docs.oracle.com/cd/E19798-01/821-1752/beafo/index.html

    #java -Xrunhprof:help
    
         HPROF: Heap and CPU Profiling Agent (JVMTI Demonstration Code)
    
    hprof usage: java -agentlib:hprof=[help]|[<option>=<value>, ...]
    
    Option Name and Value  Description                    Default
    ---------------------  -----------                    -------
    heap=dump|sites|all    heap profiling                 all
    cpu=samples|times|old  CPU usage                      off
    monitor=y|n            monitor contention             n
    format=a|b             text(txt) or binary output     a
    file=<file>            write data to file             java.hprof[{.txt}]
    net=<host>:<port>      send data over a socket        off
    depth=<size>           stack trace depth              4
    interval=<ms>          sample interval in ms          10
    cutoff=<value>         output cutoff point            0.0001
    lineno=y|n             line number in traces?         y
    thread=y|n             thread in traces?              n
    doe=y|n                dump on exit?                  y
    msa=y|n                Solaris micro state accounting n
    force=y|n              force output to <file>         y
    verbose=y|n            print messages about dumps     y
    
    Obsolete Options
    ----------------
    gc_okay=y|n
    
    Examples
    --------
      - Get sample cpu information every 20 millisec, with a stack depth of 3:
          java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname
      - Get heap usage information based on the allocation sites:
          java -agentlib:hprof=heap=sites classname

    转化HPROF log

    使用adt-bundle-windows-x86_64-20140702sdkplatform-toolshprof-conv.exe来转化。

    hprof-conv a.hprof b.hprof

    MAT分析

    http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-ma/index.html

  • 相关阅读:
    首发Zend Studio 9.0.2正式版注册破解
    PHP 中Cookie和Session的使用
    PHP设计模式职责和单例模式
    软件工程工具学习(1)Visio
    java复习(4)数字处理类
    java复习(1)java与C++区别
    微信开发(1)微信防撤回功能实现
    java复习(3)字符串、数组
    java复习(2)java基础杂记
    java复习(5)接口、继承、多态
  • 原文地址:https://www.cnblogs.com/miniren/p/4710302.html
Copyright © 2020-2023  润新知