I am writing a small android game, and whenever I first ran, everything worked fine, but it will randomly hang and start spamming this endlessly in eclipse’s LogCat
12-30 12:40:05.344: D/dalvikvm(22831): WAIT_FOR_CONCURRENT_GC blocked 5ms
12-30 12:40:05.383: D/dalvikvm(22831): GC_CONCURRENT freed 511K, 34% free 2374K/3552K, paused 1ms+2ms, total 14ms
I know it has something to do with garbage collecting, but whenever I force stop the app(the only way to close it) I lose around 5-10mb of available ram until I restart the device. does anyone know what this means and how to prevent it?
the device I am using is a verizon galaxy nexus running android 4.2.1(Cyanogenmod 10.1) and sdk/target version at 3.2(api level 13). Thanks!
You’ll be able to Google your way into a much more detailed description, but basically it just means you’re making the garbage collector work very hard.
Programming a game is different from programming a ‘normal’ app: your game probably loops countless of times.
As a result of this even a tiny memory leak can grow quickly to a real problem.
Furthermore, GC is normall your biggest friend, in gaming it is pretty much one of your enemies. Every GC run creates a little freeze since it ‘stops the world’.
I’d suggest you continue your search in specific gaming programming tutorials and how to work against the GC in those.