Memory Analyzer Tool in android?

前端 未结 7 2038
醉酒成梦
醉酒成梦 2020-11-27 16:31

I just want to know how to work with Memory analyzer tool in android. Please tell me how to do this to know about memory leaks for a particular project. Can someone give me

相关标签:
7条回答
  • 2020-11-27 16:46

    Try Using the Memory Analyzer Tool (MAT)

    Look at these articles:

    • Using DDMS
    • Track Memory Allocations
    • Avoiding memory leaks

    Also look at these SO Posts:

    • Android ==> Memory Analysing ==> Eclipse memory analyzer?
    • What Android tools and methods work best to find memory/resource leaks?
    0 讨论(0)
  • 2020-11-27 16:47

    I'd recommend taking a look at Leak Canary. It's not a memory analyzer per se, but more a leak detector. Just use your app, open and close activities and let the library do it's job. It will even tell you about where the leak occured. Just give the leak analyzer some time to do its work after the leak occured - it usually takes around 2 minutes or more until the source of the leak has been found.

    0 讨论(0)
  • 2020-11-27 16:54

    Write to hprof fails when you have not used android.permission.WRITE_EXTERNAL_STORAGE. As a special case when you are testing on device, check if your SD card is connected in Charge ONLY mode otherwise you wont have write access on SD Card

    0 讨论(0)
  • 2020-11-27 16:54
    • Install MAT.

    • Go to Tools->Android ->Android device monitor(DDMS)

    • In the top left side under Devices,select the project name and click Update Heap.

    • Then Click Dump HPROF File and saved it in desktop.

    • Then run the Command prompt and point out the Android-sdk directory.

      For an Example: hprof-conv is located in E directory. So run the command as cd android/sdk/platform-tools.

    • Then finally run this command by referring this doc to convert this file format to read it in MAT.

      E:\Android\sdk\platform-tools> hprof-conv "C:\Users\Steve\Desktop\yourfilename.hprof" "C:\Users\Steve\Desktop\leakage.hprof"

    • Now your file will converted to leakage.hprof.check this file and open it in MAT.

    Edit: Click details,then it will show the class names.In that Left Click -> Path To GC Roots ->With all references.Then it shows the class name.

    0 讨论(0)
  • 2020-11-27 16:55
    1. Open DDMS perspective in Eclipse.
    2. Select Devices tab.
    3. Choose a process you want to make a dump for.
    4. Click Dump HPROF file button. The dump will be made and MAT window will be opened, assuming MAT is installed.
    5. Choose Leak Suspects Report in the wizard window and click Finish.

    That's all. You'll se a list of possible leaks, but some of them are false-positive. I recommend you to run an activity you want to check leaks in several times and then run MAT again.

    0 讨论(0)
  • 2020-11-27 17:03

    Please update to Android studio version 1.4 or 1.5. In this version, android has supported new tool its called Analyzer Task It is very useful to avoid memory leak.

    0 讨论(0)
提交回复
热议问题