Im trying to figure out how to manually unload models/textures/shaders ect.

Halp me Intertron!

Re: Game Technologies: Graphics unloading model resources

BLANC Guillaume

DirecX runtime is a COM compliant API. It means a lot of things, but especially for your concern that each allocated object has a reference counter. The idea behind this counter is to deallocate the COM object as soon as counter's value falls down to 0. The counter is incremented at creation time, on a call to the COM base interface IUnknow::AddRef or IUnknow::QueryInterface. To decrement it, call IUnknow::Release function and the object will be automatically destroyed if its counter value is 0. Anyway, you'll should not care about what is the exact counter value, simply manage your own references to your objects and it will work. For more details and sample code, see Managing a COM Object's Lifetime and Using COM DiretX documentations.

To debug Direct3d object lifetime issues, it's very useful to use the DirectX "Break on memory leak" debug option available from DirectX control panel. It'll automatically point out unreleased objects once your application has exited.

Also, to avoid any problem and simplify DiretcX object lifetime management, I use COM smart pointers that I would recommend you to try.

Re: Game Technologies: Graphics unloading model resources

Inaki Ayucar

If you are using the .Net version of DirectX (Managed), you should unload resources with their Dispose() method.

You can also check out the ResourceManager included in the Utility Toolkit of ManagedDirectX. It does a big part of the work for you.