I’ve got a quick question about what I should/should not be disposing of in MonoGame. I know that everything I load using the ContentManager will do its own thing, but what about other graphics resources that I create manually, such as VertexBuffer, IndexBuffer, RenderTarget2D, Texture2D, SpriteBatch … and anything else that inherits from GraphicsResource?
The simplest case is the default code generated for a new MonoGame project; there’s a SpriteBatch being created with the ‘new’ keyword, and even though it’s a GraphicsResource that implements Dispose(), it never actually gets disposed, not even in the UnloadContent() method (which claims to be there to handle any non ContentManager content).
I’m asking this question because, while most of my stuff is created and managed by the ContentManager, I do have quite a few little things floating around which I’m wondering what to do with. I also create a LOT of VertexBuffers in my program, which were the source of a large memory leak until I started manually calling Dispose() on them before derefrencing their parent objects (nodes in a large recursive quadtree structure). I want to chase down and properly handle any other similar leaks, no matter how small they might be!
Thanks very much for your help