9

Can you please tell me how can I do memory profile for an android application? I want to find out how are the objects created and where did those created.

Thank you.

michael
  • 106,540
  • 116
  • 246
  • 346
  • I can't give a good answer but have you used the DDMS tool that comes with the SDK yet? Might start playing around with it until you can get a better answer. – Nathan Schwermann Oct 04 '10 at 16:26
  • You can find your answer here: http://stackoverflow.com/questions/3112671/android-memory-analysing-eclipse-memory-analyzer – Edi Oct 04 '10 at 16:27
  • Thanks. But is it possible to dump out the heap of my android application when a 'Force Close/Wait' dialog has poped up? – michael Oct 05 '10 at 01:49
  • You can use Debug.dumpHprofData() to dump the data from your Java code. You can see how to handle the uncaught exceptions here: http://stackoverflow.com/questions/601503/how-do-i-obtain-crash-data-from-my-android-application. However, – Edi Oct 05 '10 at 10:31
  • However, the "FC/Wait" dialog appears when you have a long operation on your UI thread and there is no way to know when that happens. – Edi Oct 05 '10 at 10:39
  • One way to detect and act on long operations on your UI thread is to create a watchdog thread. If you create a handler on the UI thread, and it posts a special message to itself every 5 seconds or so, you can use that to notify a spawned watchdog. The watchdog can do a time limited wait for a common semaphore that's released by the recurring message, and if the semaphore has not been released within the expected time, you can dump the heap. There's of course no guarantee that an ANR will follow, but it's likely. – David Burström Nov 11 '13 at 19:03

0 Answers0