I'm making my first game with LibGDX and Box2D, and I've realized that the memory used increases when I change screens. It starts from 150MB and progressively reaches 850. How should I deal with this? It does not seem to be a memory leak, memory is constant throughout the level, and I'm using an AssetManager to dispose everything needed.
The problem is when switching screens, since objects remain in memory. What is the best practice in this case?
Should I have a method in each class that sets every object to
null before the screen is disposed?
Another problem might be that I have a static class for all my constants (this was the method proposed in the Udacity course), could this be an issue?
Another idea described here is initializing all screens in the beginning and using them throughout the game. Though I'm not sure this could be done in my game now. Is this good practice?