Better way to Manage Assets... Need a tip :)

Hi Guys… Im trying to optimize my game, and well, its going well :slight_smile:
Im usint TexturePacker2 to optimze the images in game, i dont know well how should i manage them or pack. But i was able to pack the images and gen the atlas.

Anyway,
Heres the Class that i built following tutorials :

package br.assets;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.Disposable;


public class AssetManagement implements Disposable {

    private static final AssetManagement assetManagement = new AssetManagement();

    public static AssetManagement getAssetManager() {
        return assetManagement;
    }
    
    private AssetManager assetManager;

    
    public AssetManagement() {}

    
    public void init(AssetManager assetManager) {
        this.assetManager = assetManager;
        //load texture atlas
        assetManager.load("", TextureAtlas.class);
        //start loading assets and wait until finished
        assetManager.finishLoading();
    }

    @Override
    public void dispose() {
        assetManager.dispose();

    }

}

The tutorial suggests that i do this to load :

@Override
public void create () {

Assets.instance.init(new AssetManager());


@Override
public void resume () {
Assets.instance.init(new AssetManager());
}

Now i ask, if im creating a new AssetManager, and replacing the old one, the old AssetManager wont dispose what he already had… Wouldnt that cause memory leak?

I mean , in resume he creates a new AssetManager();

I was thinking in making in this way :

package br.assets;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.Disposable;

public class AssetManagement implements Disposable {

    private static final AssetManagement assetManagement = new AssetManagement();
    private final AssetManager assetManager;

    public AssetManagement() {
        assetManager = new AssetManager();
    }

    public static AssetManagement getInstance() {
        return assetManagement;
    }

    public void init() {

        //load texture atlas
        assetManager.load("packed/archerresources.atlas", TextureAtlas.class);
        //start loading assets and wait until finished
        assetManager.finishLoading();
    }

    @Override
    public void dispose() {
        assetManager.dispose();

    }

}

When i pause/resume, i could do this :

public void resume() {
            AssetManagement.getInstance().init();
        }

        public void pause() {
            AssetManagement.getInstance().dispose();
        }

Am i thinking wrong or im correct?

Its 1 AM here so , im sorry if im lacking something lol