Memory Management Progress

Today was a good day for memory management.

Yesterday, I read about some tools for memory management. Adobe has one, of course. And folks say it's quite good for this sort of thing. It's a full IDE, though, and it has typical Adobe pricing (e.g. $700).

Another tool I read about, TheMiner, is a homebrew memory profiler. I accidentally learned about it while reading about memory leaks on Flixel forums. As it turns out, it's a pretty comprehensive memory profiler, possibly on par with Adobe's. And what's more, it'll only set one back an easy-to-swallow $45.

So I decided to give that a shot this morning, and wow. Talk about handy! Within minutes, I had found a serious memory leak in the items screen. New objects in memory were being created 20-30 times each second as soon as an item was picked up, and would continue to bloat memory each second even after putting the item down again. That means that from the earliest game screen, skill selection, memory use started inflating.

Finding the actual leak took a few more hours. Once I did, however, the game was much more stable. A few extra objects still get created here and there, but it's like 1-3 per second, and only while dragging an object. Otherwise, it seems to stop inflating.

What's even better, TheMiner helped me spot a few functions that were being called way too many times. Some of them shouldn't have even been called in the first place. Tracking those down and bypassing/disabling them sped up performance even more.

And finally, since TheMiner does such a good job of reporting memory usage and framerate, it seemed silly to keep Flixel's built-in debugger turned on, as it adds all kinds of extra invisible sprites and text objects to the screen, which were now redundant.

When all was said and done, NEO Scavenger actually felt pretty snappy. Things seemed much smoother and faster. Framerates were back up into the 30-60 range, instead of 11-30. And memory use seemed to stay below 500MB.

That's looking pretty promising, so I'll give it some more testing Monday, and start looking into the next build upload. I'm still finding some bugs here and there that resulted from all the memory management stuff I've added, so I don't want to jump the gun and upload a broken build. But I think I'm getting close!

Anyway, it was a good day. It feels nice to have made solid strides after yesterday's slow progress.

Hope everyone has a good weekend, and see you Monday!

Comments

UltimaVirus's picture
UltimaVirus

Great news! I love hearing about how you fix these problems. :)

dcfedor's picture
dcfedor

Glad to hear it! I'm hoping some other Flash/AS3 devs will also benefit from the knowledge. There can be some tricky problems out there, and sharing the solutions we use can make life easier for us all!

Dan Fedor - Founder, Blue Bottle Games

Ephemera's picture
Ephemera

Awesome! Glad you were able to both find an affordable solution and the cause of the leak! I'm sure that we all would have gladly pitched in for such an expense if there were no alternative, however. Those of us that play are here to stay, whatever blend of magic and skills you've used to put Neoscavenger together created quite the addicting and immersing concoction. It's not quite perfect yet, but the foundation is.

dcfedor's picture
dcfedor

Thanks, that's quite generous of you! I'm hoping it won't have to come to that, of course. You folks have already helped by supporting the game!

And I like your assessment of the game: kind of a flawed gem. Historically, I think those were the most memorable types of games for me as a player :)

Dan Fedor - Founder, Blue Bottle Games