Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

java - Android memory: how to inspect memory without using Profiler?

I have a problem of OOM error (OutOfMemory) with my app. It seems that it is due to an object that takes more and more room in memory but I don't manage to find which one.

I would like to use the Android Profiler to find the problem. But I have a real time app that uses a lot the device processor and memory, and when I use the Profiler the app becomes really slow and becomes almost impossible to use (I need to use the app at least 3 minutes at normal speed in order to see the memory growing progressively).

My questions are:

  • is there a way to use the Profiler without this slowdown issue?
  • if not, are there any other tools or methodology in order to help me finding which object grows in memory?

Thanks !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can collect your app's heapdump using adb shell

adb shell am dumpheap <PID> <TARGET_FILE>

and view the exported file using android studio profiler

Alternatively, if you know when exactly in your app the OOM happens, you can collect the heapdump using this method Debug.dumpHprofData(String)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...