How to find the worst allocations in Eclipse w/ Android (Dalvik) JVM?

I wrote lots of sloppy code, quickly, to get a game up and running fast.

That’s great, worked fine, but now (weeks later) performance has slowed down enough it’s getting annoying, and I’d like to clean things up.

First, obvious, thing: I’m getting GC freeing 1.5 MB per second. That’s a lot bigger than I expected, since I’m only running at 20 FPS.

Eclipse’s DDMS view has an allocation tracker, but the frequent GC’s mean I don’t get to see what’s allocating so extensively.

Any ideas on how to catch this? Or is it just a case of “keep hitting Get Allocations button until you see something unexpected” ?

I don’t have the tools in front of me, but I dump hprof files from ddms (a button on the toolbar) then use the hprof convert tool and load them in YourKit to get a full view of allocations and such from known points when the hprof files are dumped. It’s a bit laborious, but YourKit is a fantastic tool. If you are getting 1.5MB a second obviously there is a problem somewhere. It’s certainly possible to have no runtime overhead on Android as in desktop Java.

In the end, I just hit the “get allocations” button like crazy until something big appeared, fixed that, then repeated.

Although it felt a bit stupid, I believe this took less time than faffing around with manual DDMS dumps, manual running of the hprof converter tool (what a joke that is - “hey, we broke the standard. And, uh, we’re not going to fix it. But here’s a commandline tool you can use to un-break what we broke! have fun!”), etc.

(NB: I recently tried to enable the Eclipse plugin that’s supposed to handle live hprofs of all kinds - it’s too broken, and there are no docs, just a couple of long boring youtube videos. I gave up at that point :frowning: )

Indeed. It’s tedious and silly about the conversion, but the best way I’ve found to handle difficult to find issues. YourKit has been a good friend for many years. When you are bleeding as much as you are presently the current way you are searching for things works.