Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

android - how to use ddms for memory leaks in c++ code

how to use android tool DDMS for memory leaks in c++ code i tried, by taking snapshots with NativeHeap enabled, but i am not understanding what snapshots are saying, and symbols are not resolving , no file names and line numbers are shown.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Native heap tracking in DDMS is an unsupported "stealth" feature. Getting it to work can be a bit tricky. There's an older discussion on a mailing list that may be useful.

If you're receiving data and have the UI up, you're halfway there. :-) DDMS looks for symbols in a specific location which you should be able to override with the ANDROID_SYMBOLS environment variable, and converts addresses to lines with addr2line (which it must also be able to find).

The simplest way to look for big leaks is to configure DDMS to sort the allocations by library. Let the app run for a while and see which library seems to be growing the fastest. Look at the allocations attributed to that library and see if there's a lot that are coming from the same place. Look at the stack trace and see if it makes sense to have many long-lived allocations from there. Not very rigorous, but it often does the trick.

For a more thorough examination of the heap, you can run valgrind on the device, but that's not any easier to set up the first time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...