My current project is required to load and unload significant amounts of content, and I am seeing a significant performance issue once enough loads and unloads have occurred. Specifically, inside GraphicsDevice there is an internal Microsoft.Xna.Framework.Graphics.DeviceResourceManager class, which contains a dictionary of ResourceData structs with weak references to the content. Every time there is a content load, a reference to each asset is added to this collection. However, this dictionary doesn't appear to ever be flushed, even when the referenced content has been disposed. In my tests my app performance is killed within a few hours as this collection grows aggressively.
Is there a proper way to flush this collection? Resetting the GraphicsDevice doesn't appear to be enough. I'm currently reflecting into the collection to clean things up, and it appears to be stable in initial testing. Is there a better method?
From what I can tell XNA 3.0 beta will have the same issue. I will open a bug in Connect with my work-around code and post a link.
Thanks for any help!
Bo Jordan