Is there a downside to using several content managers?

Hi! I am pondering about how to handle loading and unloading in a monogame project that I have. I handle diffrent states of my project through classes, one state(class) for menu, one for in game etc. I was thinking about having one content manager in each state and maybe two in the game state because I building a open world where I might want to load and unload assets throughout the world. Though I understand that I probebly can load all the assets once in the game state unless the world is big with lots of assets. My question is wheter there is a downside in using content managers in this way.

1 Like

I’d like to hear others’ input on this, but to my knowledge, I think that’s the “correct” way to do it, since, yeah, unloading one content manager will unload everything it has.

I am doing exactly the same thing to enable loading and unloading per state.

As far as I know the only real downside to this approach is that you would be able to load the same asset into memory multiple times (once per content manager) where this would be safely blocked using only one content manager. Of course this is easily handled by ensuring everything uses the proper content manager, but figured I would mention it.

Aside from that, the extra memory / processing per content manager is very minimal and not enough to really concern yourself with. Full disclosure I haven’t actually profiled this but switching from one ContentManager to the 5 I’m currently using did nothing to my game’s FPS and barely touched the memory.

I wrote an AssetManager class which has an array of content managers and wraps all the loading / unloading functionality throughout my game. I use an enum AssetGroup which acts as the index for which content manager an asset should be loaded into. Doing it this way isn’t necessary but by placing an accessor in your main game class everything has pretty easy access similar to the more “typical” setup of access Content through the Game class.