When I close my application, I get the following errors in the Direct3D Debug output:
Direct3D9: (INFO) :MemFini!
Direct3D9: (ERROR) :Memory still allocated! Alloc count = 20
Direct3D9: (ERROR) :Current Process (pid) = 0000162c
Direct3D9: (ERROR) :Memory Address: 05fb7d0c lAllocID=50 dwSize=000170d8, ReturnAddr=0615e508 (pid=0000162c)
Direct3D9: (ERROR) :Memory Address: 08c86594 lAllocID=1046 dwSize=00004bc4, ReturnAddr=0614d5ea (pid=0000162c)
(...)
Direct3D9: (ERROR) :Memory Address: 08d0c31c lAllocID=1471 dwSize=00001a40, ReturnAddr=0615e784 (pid=0000162c)
Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 258932 bytes
I've carefully looked over my code and the one thing I found suspect was a texture and a surface I got from the texture. I realised that surface->Release() wasn't returning 0, which means, I believe, that someone else still has a reference to it. So just to try something, I released it several times in a while loop until it returned 0. Direct3D then returned the following error:
Direct3D9: (ERROR) :A level of a mip-map has been released more often than it has been add-ref'ed! Danger!!
I don't get it. That surface is somehow referenced more than once but hasn't been "add-refed" more than once? How can I debug who is holding a reference to it?
Thanks.