RSS Feed

Hard to Find, Easy to Fix

December 8, 2017

Maybe I am getting old, but I just experienced one of the most prolonged bug chases in my career. It started with Goblin Defence crashing on Android. No messages, errors or warning. It just closed as if I had pressed an exit button.

 

My gut feeling is that it was a memory leak. But, no, the managed heap was quite small and not growing. A series of blind alleys followed. Only when I returned to my original hunch did I finally make progress. Android has a managed heap used by the Java application and a native heap for the underlying C++ framework. The latter would continue to grow until Android decided that the program was too hungry and kick it out for good. It is standard practice to terminate background processes. It is only applied to the foreground in extreme circumstances.

 

The native heap is much harder to debug. When Android Studio moved from Eclipse to IntelliJ, the monitor lost the ability to gather data for the native heap. It was an undocumented feature even before that. Without tools, it became a matter of aligning addresses with symbol tables for C++ libraries without source.

 

Again I experienced may dead ends - with the most significant being between my shoulder blades. Finally, I narrowed it down to retrieving sprites for animation (SpriteAtlas.GetSprite(name)). I reported this on a Unity3D forum.

 

The immediate workaround was to cache the sprites - something I had assumed the atlas was doing for me.

 

So, did I waste weeks on a problem with a half-hour solution? Not at all. Not at all. I learned a lot about both Unity3D and Android. I also improved the code in other places that accounted for better performance and reliability.

 

By the time you read this you will be able to play Goblin Defence on iOS or Android. Come have some fun.

 

 

 

Share on Facebook
Share on Twitter
Please reload

Featured Posts

My limited tests show that Dictionary is faster than `SortedList`. The latter uses `Array.BinarySearch` to find entries. I have read other performance...

How are C# Dictionaries so Fast?

August 27, 2018

1/5
Please reload

Recent Posts

April 12, 2018

Please reload

Archive
Please reload

Search By Tags
Please reload

Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square