GDI Resource leaks - CXTPDialogBaseImpl |
Post Reply |
Author | |
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 890 |
Post Options
Thanks(0)
Posted: 16 December 2024 at 8:47am |
When constructing a dialog derived from CXTPDialogBaseImpl the base class creates a CXTPCommandBars object. In its constructor a CXTPCustomizeDropSource object is created and in its constructor 3 icons are loaded. Our GDI resource leak tool is identifying these as resource leaks. I ran the tool because I noticed the GDI count going up in our process whenever we launch a dialog that uses this base class. Where is the DestroyIcon code supposed to go. Looks like it should be in destructor which is devoid of code. CXTPCustomizeDropSource::CXTPCustomizeDropSource(CXTPCommandBars* pCommandBars) { m_hcurDelete = XTPResourceManager()->LoadCursor(XTP_IDC_COMMANDBARS_DRAGDELETE); m_hcurMove = XTPResourceManager()->LoadCursor(XTP_IDC_COMMANDBARS_DRAGMOVE); m_hcurCopy = XTPResourceManager()->LoadCursor(XTP_IDC_COMMANDBARS_DRAGCOPY); m_pSheet = NULL; m_pCommandBars = pCommandBars; m_hwndCapture = 0; m_pControl = 0; m_bMove = FALSE; m_bCopyOnly = FALSE; m_pTarget = NULL; } CXTPCustomizeDropSource::~CXTPCustomizeDropSource() { } This is in the current release.
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 297 |
Post Options
Thanks(0)
|
Hello, What GDI resource leak tool you used for identifying resource leaks? Regards, Artem Gontarenko
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 297 |
Post Options
Thanks(0)
|
How I can to reproduce this?
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 890 |
Post Options
Thanks(0)
|
We have a tool we wrote that hooks various APIs and tracks resource allocations. It uses debugging APIs to capture call stacks on allocation. When it lists any outstanding allocations we can double click an entry it shows on a call stack and it opens the source file in Visual Studio. It lets us start tracking and stop tracking on demand. So, I started tracking, brought up a dialog derived from the CJ class, closed the dialog and stopped tracking. Then I listed all outstanding resources and saw the "icon" resources and followed the stack and code. I fixed this in the destructor by checking for non-null members and calling DestroyIcon. Just set a breakpoint in the constructor and destructor and you can see the allocation and see in the destructor the members are non null.
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 890 |
Post Options
Thanks(0)
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |