Dispose of your assets in dispose()
or when you are done with them and need to free up memory (such as switching to a new stage that uses different assets).
The game's dispose
method is called in the Activity's onPause()
method, but only if the Activity is being finished, so you are safe if you only dispose in dispose()
. If the application process remains open, dispose()
has been called, so you're good. And at this point, if your game reopens, create()
will be called again so you don't need to worry about reloading in resume()
.
If for some reason Android force-quits your game, then all the memory is cleared up anyway and you have no need to worry about leaks.
And the reason why you must dispose in dispose()
is for cases where the user backs out of your game Activity but the Application process is not shut down. If the user launches the game Activity again, all the non-disposed assets from the previous instance are still held in memory and have now leaked.