   debug memory problem
  How do I go about fixing all those errors? It was my understaing that direct x freed all the momery it used (eg textures, models etc) when it closed yet all the errors seem to be coming from Direct3D9...'d3d.exe': Loaded 'H:\cpp\d3d\Debug\d3d.exe', Symbols loaded.'d3d.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\user32.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\version.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\winmm.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\D3DX9d_36.dll''d3d.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.'d3d.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.'d3d.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\msctf.dll''d3d.exe': Loaded 'C:\Program Files\SiteAdvisor\6253\saHook.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\d3d9d.dll''d3d.exe': Loaded 'C:\WINDOWS\system32\d3dx9d_33.dll'Direct3D9: :====> ENTER: DLLMAIN(00e4e6e0): Process Attach: 00000314, tid=00000e7cDirect3D9: :====> EXIT: DLLMAIN(00e4e6e0): Process Attach: 00000314Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.Direct3D9: (INFO) :======================= Hal HWVP device selectedDirect3D9: (INFO) :HalDevice Driver style 9Direct3D9: :Subclassing window 000603b0Direct3D9: :StartExclusiveModeDirect3D9: :Window 0003004a is on top of us!!Direct3D9: :Window 0003004a is on top of us!!Direct3D9: :WM_ACTIVATEAPP: BEGIN Activating app pid=00000314, tid=00000e7cDirect3D9: :*** Active state changingDirect3D9: :WM_ACTIVATEAPP: DONE Activating app pid=00000314, tid=00000e7cD3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f.  This is ok.Direct3D9: :====> ENTER: DLLMAIN(00e4e6e0): Process Detach 00000314, tid=00000e7cDirect3D9: (INFO) :MemFini!Direct3D9: (WARN) :Memory still allocated!  Alloc count = 115Direct3D9: (WARN) :Current Process (pid) = 00000314Direct3D9: (WARN) :Memory Address: 00c74af8 lAllocID=1 dwSize=000047f8, (pid=00000314)Direct3D9: (WARN) :  Stack Back TraceDirect3D9: (ERROR) :    [0] : Address 00E4E4CBDirect3D9: (ERROR) :    [1] : Address 00E4E59BDirect3D9: (ERROR) :    [2] : Address 00E4E440Direct3D9: (ERROR) :    [3] : Address 00E42DB4Direct3D9: (ERROR) :    [4] : Address 4FDFAF2EDirect3D9: (ERROR) :    [5] : Address 00419058Direct3D9: (ERROR) :    [6] : Address 004178DEDirect3D9: (ERROR) :    [7] : Address 0042D358Direct3D9: (ERROR) :    [8] : Address 0042D0BFDirect3D9: (ERROR) :    [9] : Address 7C816D4FDirect3D9: (ERROR) :    [10] : Address 00000000Direct3D9: (ERROR) :    [11] : Address 00000000Direct3D9: (ERROR) :    [12] : Address 00000000Direct3D9: (ERROR) :    [13] : Address 00000000Direct3D9: (ERROR) :    [14] : Address 00000000Direct3D9: (ERROR) :    [15] : Address 00000000Direct3D9: (WARN) :Memory Address: 00c7b770 lAllocID=10 dwSize=000013d4, (pid=00000314)Direct3D9: (WARN) :  Stack Back TraceDirect3D9: (ERROR) :    [0] : Address 00E450D4Direct3D9: (ERROR) :    [1] : Address 00E45EBFDirect3D9: (ERROR) :    [2] : Address 00E465F8Direct3D9: (ERROR) :    [3] : Address 00E42DD5Direct3D9: (ERROR) :    [4] : Address 4FDFAF2EDirect3D9: (ERROR) :    [5] : Address 00419058Direct3D9: (ERROR) :    [6] : Address 004178DEDirect3D9: (ERROR) :    [7] : Address 0042D358Direct3D9: (ERROR) :    [8] : Address 0042D0BFDirect3D9: (ERROR) :    [9] : Address 7C816D4FDirect3D9: (ERROR) :    [10] : Address 00000000Direct3D9: (ERROR) :    [11] : Address 00000000Direct3D9: (ERROR) :    [12] : Address 00000000Direct3D9: (ERROR) :    [13] : Address 00000000Direct3D9: (ERROR) :    [14] : Address 00000000Direct3D9: (ERROR) :    [15] : Address 00000000Direct3D9: (WARN) :Memory Address: 00c7b578 lAllocID=11 dwSize=00000014, (pid=00000314)Direct3D9: (WARN) :  Stack Back Trace......Direct3D9: (WARN) :Total Memory Unfreed From Current Process = 379046 bytesDirect3D9: :====> EXIT: DLLMAIN(00e4e6e0): Process Detach 00000314The program '[788] d3d.exe: Native' has exited with code 0 (0x0).
  Resources in DirectX are COM objects, and should be Release()'d when not needed anymore. I strongly recommend using a COM-aware smart pointer like CComPtr<T>, which handles AddRef/Release for you.   ;  shouldn't this have releashed them?void d3d_destroy(void){if (d3d_vertex_buffer){d3d_vertex_buffer->Release();d3d_vertex_buffer = NULL;}if (d3d_device){d3d_device->Release();d3d_device = NULL;}if (d3d){d3d->Release();d3d = NULL;}}