In AndroidApplication and AndroidFragmentApplication classes, they hold an instance of this.*
on Gdx.*
(Especially this line Gdx.app = this;
).
But if fragment/activity get destroyed these references are still alive, so they create a memroy leak.
Here is an example with LeakCanary:
So these references should not exist after the end of their expected lifetime. Simply we can do this:
Gdx.app = null;
Gdx.input = null;
Gdx.audio = null;
Gdx.files = null;
Gdx.graphics = null;
Gdx.net = null;
In onDestroy
method of activties/fragments to avoid memory leak.
And Leak Canary will not show any memory leaks related to libgdx: