Print Page | Close Window

GDI Resource leaks - CXTPDialogBaseImpl

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=24536
Printed Date: 18 December 2024 at 2:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: GDI Resource leaks - CXTPDialogBaseImpl
Posted By: rdhd
Subject: GDI Resource leaks - CXTPDialogBaseImpl
Date 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.



Replies:
Posted By: agontarenko
Date Posted: 17 December 2024 at 4:20am
Hello,

What GDI resource leak tool you used for identifying resource leaks?

Regards,
Artem Gontarenko


Posted By: agontarenko
Date Posted: 17 December 2024 at 4:22am
How I can to reproduce this?


Posted By: rdhd
Date Posted: 17 December 2024 at 9:33am
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.


Posted By: rdhd
Date Posted: 17 December 2024 at 10:43am
uploads/3213/CJLeak.zip" rel="nofollow - uploads/3213/CJLeak.zip

Video of ISpy detecting GdiCursor leak in toolkit pro.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net