Home Game Development libgdx – Disposing objects when altering screens

libgdx – Disposing objects when altering screens

0
libgdx – Disposing objects when altering screens

[ad_1]

I’m making my first recreation with LibGDX and Box2D, and I’ve realized that the reminiscence used will increase after I change screens. It begins from 150MB and progressively reaches 850. How ought to I cope with this? It doesn’t appear to be a reminiscence leak, reminiscence is fixed all through the extent, and I’m utilizing an AssetManager to dispose all the things wanted.

The downside is when switching screens, since objects stay in reminiscence. What is the most effective follow on this case?
Should I’ve a way in every class that units each object to null earlier than the display screen is disposed?
Another downside is likely to be that I’ve a static class for all my constants (this was the strategy proposed within the Udacity course), might this be a problem?

Another concept described right here is initializing all screens at first and utilizing them all through the sport. Though I’m undecided this could possibly be completed in my recreation now. Is this good follow?

I attempted profiling a bit though it is the primary time, listed below are some outcomes. The sudden ‘hops’ are when switching screens.
enter image description here

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here