• Advertisement
Sign in to follow this  

What if break on AllocID breaks in garbage?

This topic is 4584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, having some memory leaks in my DX code, I've tried to find them by entering their AllocID into the Break on AllocID to the DX control panel.
Direct3D9: (INFO) :MemFini!
Direct3D9: (ERROR) :Memory still allocated!  Alloc count = 250
Direct3D9: (ERROR) :Current Process (pid) = 000002d8
Direct3D9: (ERROR) :Memory Address: 03259474 lAllocID=13 dwSize=000047f8, ReturnAddr=09de159b (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0a0b0194 lAllocID=21 dwSize=000012fc, ReturnAddr=09dd81d4 (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0325fd94 lAllocID=22 dwSize=00000008, ReturnAddr=09dd82c2 (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0a0b14c4 lAllocID=23 dwSize=00000620, ReturnAddr=09dd989f (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0a0b2dec lAllocID=203 dwSize=0000180c, ReturnAddr=09dd81d4 (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0325ffac lAllocID=204 dwSize=00000014, ReturnAddr=09dd82c2 (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0a0b1b1c lAllocID=234 dwSize=000006bc, ReturnAddr=09df2fbb (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0325dca4 lAllocID=236 dwSize=00001734, ReturnAddr=09de4a89 (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0325ff0c lAllocID=238 dwSize=00000008, ReturnAddr=09de4bcd (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0a0b4f3c lAllocID=240 dwSize=00003508, ReturnAddr=09de159b (pid=000002d8)
Direct3D9: (ERROR) :Memory Address: 0325f40c lAllocID=241 dwSize=00000198, ReturnAddr=09de159b (pid=000002d8)
Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 52692 bytes

It breaks, but it does not stand in my source, rather the call stack contains d3d9.dll and ntdll.dll addresses without any symbol info. I've already tried several of them, but no luck, neither of them break at any useful place. Maybe this is broken in the April 2005 SDK? Did any of you successfully used it? Thanks for your help, kp

Share this post


Link to post
Share on other sites
Advertisement
Make sure you're working down from the highest AllocID, so in your case, try breaking on 241. In most cases, the objects designated by lower IDs are not released because they are still referenced by objects with higher IDs.

Share this post


Link to post
Share on other sites
Hi,

thanks for the reply! Unfortuantely I've already tried that, but that one was unusable too.. what else could it be?

kp

Share this post


Link to post
Share on other sites
If none of the AllocIDs have entries anywhere in their complete call stacks (indicating internal calls by something like D3DX to D3D acting on your behalf), then obtaining some symbols for the Microsoft parts of the call stack may give you a clue. Here's how:

1) Load your solution into MSVC.NET as usual.


2) In the "Solution Explorer", right click on the Solution item (the bit that says "Solution 'blah' (1 Project)" and select Properties from the menu that appears.


3) Under Common Properties, select the "Debug Symbol Files" entry.


4) Add the following new path to the "Search these paths for symbol files:" list: SRV*c:\localsymbols*http://msdl.microsoft.com/download/symbols

That will first search c:\localsymbols and then second search the MS symbol server in that order.


5) Apply that change and OK the dialog then start your project in the MSVC debugger with Break on AllocId enabled.

You'll notice that your project takes quite a while to start, this is because MSVC is downloading the symbols for each of the DLLs your application is using, including the Direct3D and D3DX ones.

When the AllocId breakpoint fires, when you look down the call stack, the random addresses for the D3D and Windows DLLs will have changed into function names.


6) Stop the debugger and go to the Debug Symbol Files list again and modify the path so that it reads: SRV*c:\localsymbols

The reason for doing this is to stop MSVC from connecting to the MS server for non-Microsoft DLLs; It always searches the local path and then the server if it can't find the symbols locally, but for non-MS DLLs it never will find the symbols locally (or on the server).



Hopefully something in the call stack will give you more of a clue about which object (including ones created by D3DX functions/interfaces) hasn't been released properly.

Share this post


Link to post
Share on other sites
Hi and thanks again!

After using these symbols, I've fonud the following:
there are three points in the code where it breaks
-CreateDevice()
-GetDeviceCaps()
-Direct3DCreate()

the Device should not be released befor Reset, I think. the GetDeviceCaps does not return anything that I should Release() afterwards. Neither the Direct3DCreate (at least, not while my program is running).

Here are the call stacks, is you are interested:

Direct3D9: (ERROR) :Memory Address: 0325913c lAllocID=13 dwSize=000047f8, ReturnAddr=09e9159b (pid=00000f8c)
> ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!D3DMalloc() + 0x5b
d3d9d.dll!MallocAligned() + 0x2b
d3d9d.dll!operator new() + 0x20
d3d9d.dll!_Direct3DCreate9@4() + 0xf4
d3d9.dll!4fdfaf2e()


Direct3D9: (ERROR) :Memory Address: 0a160194 lAllocID=21 dwSize=000012fc, ReturnAddr=09e881d4 (pid=00000f8c)
> ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!RegisterD3DCaps() + 0x84
d3d9d.dll!GetDX8HALCaps() + 0xef
d3d9d.dll!CEnum::CEnum() + 0x528
d3d9d.dll!_Direct3DCreate9@4() + 0x115
d3d9.dll!4fdfaf2e()


Direct3D9: (ERROR) :Memory Address: 0325fa5c lAllocID=22 dwSize=00000008, ReturnAddr=09e882c2 (pid=00000f8c)
> ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!RegisterD3DCaps() + 0x172
d3d9d.dll!GetDX8HALCaps() + 0xef
d3d9d.dll!CEnum::CEnum() + 0x528
d3d9d.dll!_Direct3DCreate9@4() + 0x115
d3d9.dll!4fdfaf2e()


Direct3D9: (ERROR) :Memory Address: 0a1614c4 lAllocID=23 dwSize=00000620, ReturnAddr=09e8989f (pid=00000f8c)
> ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!CEnum::CEnum() + 0x6cf
d3d9d.dll!_Direct3DCreate9@4() + 0x115
d3d9.dll!4fdfaf2e()


Direct3D9: (ERROR) :Memory Address: 0a162b54 lAllocID=203 dwSize=0000180c, ReturnAddr=09e881d4 (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!RegisterD3DCaps() + 0x84
d3d9d.dll!AddSoftwareDevice() + 0x66
d3d9d.dll!CEnum::GetRefCaps() + 0x4d
d3d9d.dll!CEnum::GetAdapterCaps() + 0x26
d3d9d.dll!CEnum::GetDeviceCaps() + 0x1a7
> DirectX9Manager.dll!CD3DEnumeration::EnumerateDevices(D3DAdapterInfo * pAdapterInfo=0x092d7088, CArrayList * pAdapterFormatList=0x0012f7b4) Line 393 + 0x26 C++
DirectX9Manager.dll!CD3DEnumeration::Enumerate() Line 348 + 0x10 C++
DirectX9Manager.dll!DirectX9Manager::Init(CWinApp * p_mainApp=0x00666970) Line 101 + 0xb C++
3DClick.exe!SHedApp::InitCC() Line 1170 C++
3DClick.exe!SHedApp::InitInstance() Line 523 + 0xb C++


Direct3D9: (ERROR) :Memory Address: 0325ff0c lAllocID=204 dwSize=00000014, ReturnAddr=09e882c2 (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!RegisterD3DCaps() + 0x172
d3d9d.dll!AddSoftwareDevice() + 0x66
d3d9d.dll!CEnum::GetRefCaps() + 0x4d
d3d9d.dll!CEnum::GetAdapterCaps() + 0x26
d3d9d.dll!CEnum::GetDeviceCaps() + 0x1a7
> DirectX9Manager.dll!CD3DEnumeration::EnumerateDevices(D3DAdapterInfo * pAdapterInfo=0x092d7088, CArrayList * pAdapterFormatList=0x0012f7b4) Line 393 + 0x26 C++
DirectX9Manager.dll!CD3DEnumeration::Enumerate() Line 348 + 0x10 C++
DirectX9Manager.dll!DirectX9Manager::Init(CWinApp * p_mainApp=0x00666970) Line 101 + 0xb C++
3DClick.exe!SHedApp::InitCC() Line 1170 C++
3DClick.exe!SHedApp::InitInstance() Line 523 + 0xb C++


Direct3D9: (ERROR) :Memory Address: 0a161b1c lAllocID=234 dwSize=000006bc, ReturnAddr=09ea2fbb (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!_D3D9CreateDirectDrawObject@24() + 0x5b
d3d9d.dll!_FetchDirectDrawData() + 0xac
d3d9d.dll!_InternalDirectDrawCreate() + 0x1e2
d3d9d.dll!CEnum::CreateDevice() + 0x626
> DirectX9Manager.dll!DDRenderingView::DDRenderingView(CWnd * p_View=0x092eee88, CD3DSettings & p_d3dSettings={...}, EM::ElementManager * p_elementManager=0x092ed730, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 268 + 0x4f C++
DirectX9Manager.dll!DirectX9Manager::AddView(EM::ElementManager * p_elementManager=0x092ed730, CWnd * p_pView=0x092eee88, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 146 + 0x38 C++
3DClick.exe!SHed3DView::OnInitialUpdate() Line 612 + 0x24 C++


Direct3D9: (ERROR) :Memory Address: 0325d96c lAllocID=236 dwSize=00001734, ReturnAddr=09e94a89 (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!_FetchDirectDrawData() + 0x339
d3d9d.dll!_InternalDirectDrawCreate() + 0x1e2
d3d9d.dll!CEnum::CreateDevice() + 0x626
> DirectX9Manager.dll!DDRenderingView::DDRenderingView(CWnd * p_View=0x092eee88, CD3DSettings & p_d3dSettings={...}, EM::ElementManager * p_elementManager=0x092ed730, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 268 + 0x4f C++
DirectX9Manager.dll!DirectX9Manager::AddView(EM::ElementManager * p_elementManager=0x092ed730, CWnd * p_pView=0x092eee88, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 146 + 0x38 C++
3DClick.exe!SHed3DView::OnInitialUpdate() Line 612 + 0x24 C++


Direct3D9: (ERROR) :Memory Address: 0325fe64 lAllocID=238 dwSize=00000008, ReturnAddr=09e94bcd (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!_FetchDirectDrawData() + 0x47d
d3d9d.dll!_InternalDirectDrawCreate() + 0x1e2
d3d9d.dll!CEnum::CreateDevice() + 0x626
> DirectX9Manager.dll!DDRenderingView::DDRenderingView(CWnd * p_View=0x092eee88, CD3DSettings & p_d3dSettings={...}, EM::ElementManager * p_elementManager=0x092ed730, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 268 + 0x4f C++
DirectX9Manager.dll!DirectX9Manager::AddView(EM::ElementManager * p_elementManager=0x092ed730, CWnd * p_pView=0x092eee88, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 146 + 0x38 C++
3DClick.exe!SHed3DView::OnInitialUpdate() Line 612 + 0x24 C++


Direct3D9: (ERROR) :Memory Address: 0a1649ac lAllocID=240 dwSize=00003508, ReturnAddr=09e9159b (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!D3DMalloc() + 0x5b
d3d9d.dll!MallocAligned() + 0x2b
d3d9d.dll!operator new() + 0x20
d3d9d.dll!CEnum::CreateDevice() + 0x7f5
> DirectX9Manager.dll!DDRenderingView::DDRenderingView(CWnd * p_View=0x092eee88, CD3DSettings & p_d3dSettings={...}, EM::ElementManager * p_elementManager=0x092ed730, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 268 + 0x4f C++
DirectX9Manager.dll!DirectX9Manager::AddView(EM::ElementManager * p_elementManager=0x092ed730, CWnd * p_pView=0x092eee88, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 146 + 0x38 C++
3DClick.exe!SHed3DView::OnInitialUpdate() Line 612 + 0x24 C++


Direct3D9: (ERROR) :Memory Address: 0a16220c lAllocID=241 dwSize=00000198, ReturnAddr=09e9159b (pid=00000f8c)
ntdll.dll!7c901230()
d3d9d.dll!_MemAlloc() + 0x110
d3d9d.dll!D3DMalloc() + 0x5b
d3d9d.dll!MallocAligned() + 0x2b
d3d9d.dll!operator new() + 0x20
d3d9d.dll!CBaseDevice::Init() + 0x46
d3d9d.dll!CEnum::CreateDevice() + 0xb13
> DirectX9Manager.dll!DDRenderingView::DDRenderingView(CWnd * p_View=0x092eee88, CD3DSettings & p_d3dSettings={...}, EM::ElementManager * p_elementManager=0x092ed730, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 268 + 0x4f C++
DirectX9Manager.dll!DirectX9Manager::AddView(EM::ElementManager * p_elementManager=0x092ed730, CWnd * p_pView=0x092eee88, const RenderingWindowType & p_rViewType=SceneRenderingWindow) Line 146 + 0x38 C++
3DClick.exe!SHed3DView::OnInitialUpdate() Line 612 + 0x24 C++



None of them contain any D3dxFont or D3dxLine, which should cause this on Reset()

Direct3D9: (ERROR) :All user created stateblocks must be freed before Reset can succeed. Reset Fails.



Now I've tried it on other computer with different DX SKD version, but everything is the same there, so it must be my fault somehow, not the SDK's
Any ideas?

kp

Share this post


Link to post
Share on other sites
The only thing that sprang to mind was that I saw a highly similar query on the DirectXDev mailing list recently. From the looks of it, it's you posting there too. I haven't really got much to add to that discussion other than to recommend you disable as much of the resource creation as possible to see if you can narrow down the cause. (For instance, comment out all use of ID3DXFont and ID3DXLine, switch to non-texture objects etc.)

The lower allocIDs are usually simply the D3D device itself and stuff that is created during initialisation. The first allocID that has anything to do with resources explicitly allocated by your program would probably be the 203. According to the callstacks you posted to DirectXDev, that stems from some enumeration code in a DLL you created (DirectX9Manager.dll).

That would probably be a good place to start looking: disable everything except device creation and your enumeration code. If you still get unreleased objects at program shutdown, there's something wrong there. You may also want to post that code here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement