I tried using the dispose function on a texture2d but that caused problems and I'm pretty sure it's not what I'm meant to use.
What should I use to basically unload content? Does the content manager keep track itself or is there something I have to do?
Take a look at my answers here and possibly here.
The
ContentManager
"owns" all the content that it loads and is responsible for unloading it. The only way you should unload content that a ContentManager has loaded is by usingContentManager.Unload()
(MSDN).If you are not happy with this default behaviour of ContentManager, you can replace it as described in this blog post.
Any textures or other unload-able resources that you create yourself without going through
ContentManager
should be disposed (by callingDispose()
) in yourGame.UnloadContent
function.If you want to dispose a texture, the easiest way to do it:
If you want to dispose all content after exiting the game, the best way to do it:
If you want to dispose only texture after exiting the game: