I'm trying to wrap my head around how memory management works in XNA 4.0 I've created a screen management test and when I close a screen, the ContentManager created by that screen is unloaded. I have used ANTS Memory Manager to look at how the memory usage is altered when I do this, and it gives me some results which makes me scratch my head.

The game starts with loading two textures (435kB and 48,3kB) which puts the usage at about 61MB. Then, when I delete the screen and runs Unload on the ContentManager, the memory usage drops to 56,5MB but instantly after goes up to 64,8MB.

Am I doing something wrong or is this usual for XNA games? Do I have to dispose of everything the ContentManager loads seperatly or do I need to do something more to the ContentManager?

Thanks in advance!


I suppose it all depends on what actually happens after screen deletion. In general all (at least standard) resources loaded by Load<T> method of ContentManager are automatically disposed, so you need to dispose additionally only any other resources.

P.S. Even simple CLR Profiler allows you to see what objects actually allocated in memory, that's what profilers are for! Why not to see it yourself?

| improve this answer | |

Your Answer

