Print Page | Close Window

Custom Data Provider, Event Label list memory leak

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=13027
Printed Date: 16 May 2024 at 1:08pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Custom Data Provider, Event Label list memory leak
Posted By: prashant
Subject: Custom Data Provider, Event Label list memory leak
Date Posted: 29 December 2008 at 7:04am
Hi Oleg,

In VC 6.0 environment while debugging I encountered memory leaks in
Calendar Control.

For Custom data provider, I gone through SQL Sample and tried following code with no succes.

if (m_pSQLDataProvider)
    {
        m_pSQLDataProvider->Close();

        m_pSQLDataProvider->InternalRelease();
    }
    m_pSQLDataProvider = NULL;

For Event Labels, I am creating Label list and setting it using SetLabelList() function in a loop. I never deleting it.

Following code is getting executed continuously in a loop:


CXTPCalendarEventLabels * copyCalendarEventLabels = NULL;

copyCalendarEventLabels = new CXTPCalendarEventLabels();
copyCalendarEventLabels->InitDefaultValues();

for (int iCount = 0; iCount < 8; iCount++)
{
CXTPCalendarEventLabel * copyEventLabel = new
                        CXTPCalendarEventLabel(iCount,
                        clr,
                        szName);

copyCalendarEventLabels->InsertAt(iCount,
                           copyEventLabel );

}

Custom Data Provider and Event Label List

LEAKS:

1) Custom Data Provider


:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarMemoryDataProvider.cpp(402) : {41361} client block at 0x02166148, subtype 0, 28 bytes long.
a CObject object at $02166148, 28 bytes long
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarMemoryDataProvider.cpp(576) : {41360} normal block at 0x02166100, 12 bytes long.
 Data: <        Ha  > 00 00 00 00 00 00 00 00 48 61 16 02
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarMemoryDataProvider.cpp(576) : {41359} normal block at 0x021660B8, 12 bytes long.
 Data: < a          > 00 61 16 02 00 00 00 00 00 00 00 00
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarMemoryDataProvider.cpp(576) : {41358} normal block at 0x02166070, 12 bytes long.
 Data: <¸`          > B8 60 16 02 00 00 00 00 00 00 00 00

2) Event Label List

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarEventLabel.cpp(145) : {41281} client block at 0x0215FCA0, subtype 0, 44 bytes long.
a CXTPCalendarEventLabel object at $0215FCA0, 44 bytes long
strcore.cpp(118) : {41279} normal block at 0x021A89B0, 24 bytes long.
 Data: <            Anni> 01 00 00 00 0B 00 00 00 0B 00 00 00 41 6E 6E 69
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarEventLabel.cpp(142) : {41277} client block at 0x0215FF10, subtype 0, 44 bytes long.
a CXTPCalendarEventLabel object at $0215FF10, 44 bytes long
strcore.cpp(118) : {41276} normal block at 0x0215FEB8, 21 bytes long.
 Data: <            Birt> 01 00 00 00 08 00 00 00 08 00 00 00 42 69 72 74
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarEventLabel.cpp(139) : {41274} client block at 0x0215FDE8, subtype 0, 44 bytes long.
a CXTPCalendarEventLabel object at $0215FDE8, 44 bytes long




Replies:
Posted By: prashant
Date Posted: 30 December 2008 at 12:27am
Hello Codejock Support team,

Any hint for memory leak issue?


Posted By: Oleg
Date Posted: 30 December 2008 at 1:32am
Hi,
After you call SetLabelList add line
CMDTARGET_RELEASE(copyCalendarEventLabels );


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: prashant
Date Posted: 30 December 2008 at 1:44am
Thanks Oleg.
What to do for custom data provider?

Also added following line :
CMDTARGET_RELEASE(copyCalendarEventLabels );

But still getting following leaks:

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\Calendar\XTPCalendarEventLabel.cpp(133) : {48387} client block at 0x021BE918, subtype 0, 44 bytes long.
a CXTPCalendarEventLabel object at $021BE918, 44 bytes long


void CXTPCalendarEventLabels::InitDefaultValues()
{
     RemoveAll();

     //XTP_CALENDAR_NONE_LABEL_ID = 0
     CXTPCalendarEventLabel* pLabel;
     pLabel = new CXTPCalendarEventLabel(0, RGB(255, 255, 255), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_NONE));
     InsertAt(0, pLabel);

     pLabel = new CXTPCalendarEventLabel(1, RGB(255, 148, 132), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_IMPORTANT));
     InsertAt(1, pLabel);

     pLabel = new CXTPCalendarEventLabel(2, RGB(132, 156, 231), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_BUSINESS));
     InsertAt(2, pLabel);

     pLabel = new CXTPCalendarEventLabel(3, RGB(165, 222, 99), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_PERSONAL));
     InsertAt(3, pLabel);

     pLabel = new CXTPCalendarEventLabel(4, RGB(231, 231, 214), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_VACATION));
     InsertAt(4, pLabel);

     pLabel = new CXTPCalendarEventLabel(5, RGB(255, 181, 115), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_MUSTATTEND));
     InsertAt(5, pLabel);

     pLabel = new CXTPCalendarEventLabel(6, RGB(132, 239, 247), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_TRAVELREQUIRED));
     InsertAt(6, pLabel);

     pLabel = new CXTPCalendarEventLabel(7, RGB(214, 206, 132), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_NEEDSPREPARATION));
     InsertAt(7, pLabel);

     pLabel = new CXTPCalendarEventLabel(8, RGB(198, 165, 247), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_BIRTHDAY));
     InsertAt(8, pLabel);

     pLabel = new CXTPCalendarEventLabel(9, RGB(165, 206, 198), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_ANNIVERSARY));
     InsertAt(9, pLabel);

     pLabel = new CXTPCalendarEventLabel(10, RGB(255, 231, 115), XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_EVENT_LABEL_PHONECALL));
     InsertAt(10, pLabel);
}


Posted By: prashant
Date Posted: 30 December 2008 at 7:58am
Please suggest alternative or modifications if any...


Posted By: Oleg
Date Posted: 31 December 2008 at 2:18am

Not sure what you see now.

if you comment whole custom label block do you see leak ?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: prashant
Date Posted: 31 December 2008 at 3:52am
Thanks Oleg.

Removed both the leaks by doing following:

1) For Label Leaks

if(NULL != m_pCalendarEventLabels)
{
       m_pCalendarEventLabels->RemoveAll();
      CMDTARGET_RELEASE(m_pCalendarEventLabels);
      delete m_pCalendarEventLabels;
      m_pCalendarEventLabels = NULL;
 }

Also I commented Out call:
//m_pCalendarEventLabels->InitDefaultValues();

Is it ok if I comment out this line?

2) For Custom Memory Provider Leaks

In the desstructor:-

CXTPCalendarData* pData = GetCalendarCtrl().GetDataProvider();

if(pData)
 {
      pData->ClearCache();
      CMDTARGET_RELEASE(pData);
      pData = NULL;
 }

If I remove ClearCache() then there is Huge leak in Data Provider and Event.

Removing those leaks, now my VC++ 6.0 IDE showing me LEAKS in following components of Codejock (I am sharing only few of those LEAKS),
Please find attached file for List of all Leaks.
uploads/20081231_035742_CodeJock-Memory.zip - uploads/20081231_035742_CodeJock-Memory.zip

Please note I am using various Codejock Components in my project such as

1) Edit Control
2) Combobox
3) Toolbar
4) Buttons

Please share your views:


C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControlEdit.cpp(163) : {22886} client block at 0x021A14D8, subtype 0, 80 bytes long.

a CXTPCommandBarEditCtrl object at $021A14D8, 80 bytes long

strcore.cpp(118) : {22867} normal block at 0x021A2A78, 52 bytes long.

 Data: <    '   '   Type> 01 00 00 00 27 00 00 00 27 00 00 00 54 79 70 65

strcore.cpp(118) : {22866} normal block at 0x021A2A20, 28 bytes long.

 Data: <             Key> 02 00 00 00 0F 00 00 00 0F 00 00 00 20 4B 65 79

strcore.cpp(118) : {22864} normal block at 0x021A2940, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControlEdit.cpp(42) : {22863} client block at 0x021A2748, subtype 0, 436 bytes long.

a CXTPControlEdit object at $021A2748, 436 bytes long

afxtempl.h(370) : {22862} normal block at 0x021A26F0, 20 bytes long.

 Data: <Ð"  à$  ÍÍÍÍÍÍÍÍ> D0 22 1A 02 E0 24 1A 02 CD CD CD CD CD CD CD CD

strcore.cpp(118) : {22861} normal block at 0x021A2698, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControlButton.cpp(35) : {22860} client block at 0x021A24E0, subtype 0, 372 bytes long.

a CXTPControlButton object at $021A24E0, 372 bytes long

strcore.cpp(118) : {22858} normal block at 0x021A2488, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControlButton.cpp(35) : {22857} client block at 0x021A22D0, subtype 0, 372 bytes long.

a CXTPControlButton object at $021A22D0, 372 bytes long

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControls.cpp(1675) : {22856} client block at 0x021A2248, subtype 0, 68 bytes long.

a CXTPOriginalControls object at $021A2248, 68 bytes long

afxtempl.h(370) : {22841} normal block at 0x021A1910, 20 bytes long.

 Data: <X   H'  H'  ÍÍÍÍ> 58 17 1A 02 48 27 1A 02 48 27 1A 02 CD CD CD CD

strcore.cpp(118) : {22840} normal block at 0x021A1600, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControlButton.cpp(35) : {22839} client block at 0x021A1758, subtype 0, 372 bytes long.

a CXTPControlButton object at $021A1758, 372 bytes long

strcore.cpp(118) : {22836} normal block at 0x021A16E0, 52 bytes long.

 Data: <    '   '   Type> 01 00 00 00 27 00 00 00 27 00 00 00 54 79 70 65

strcore.cpp(118) : {22835} normal block at 0x021A1688, 28 bytes long.

 Data: <             Key> 02 00 00 00 0F 00 00 00 0F 00 00 00 20 4B 65 79

strcore.cpp(118) : {22808} normal block at 0x021A1050, 20 bytes long.

 Data: <            Keyw> 01 00 00 00 07 00 00 00 07 00 00 00 4B 65 79 77

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPToolBar.cpp(247) : {22807} normal block at 0x021A0FB8, 80 bytes long.

 Data: <ô ^ Xð      ÍÍÍÍ> F4 8F 5E 01 58 F0 19 02 00 00 00 00 CD CD CD CD

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPCommandBar.cpp(200) : {22806} normal block at 0x021A0F40, 48 bytes long.

 Data: <Xð   âJ_        > 58 F0 19 02 88 E2 4A 5F 00 00 00 00 01 00 00 00

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControls.cpp(51) : {22805} client block at 0x021A0EB8, subtype 0, 68 bytes long.

a CXTPControls object at $021A0EB8, 68 bytes long

strcore.cpp(118) : {22804} normal block at 0x021A0D80, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72

D:\Project\Source\PIM90\Pim\SplitWnd\CMCSplitMDIChildWnd.cpp(74) : {22803} client block at 0x0219F058, subtype 0, 432 bytes long.

a CMVToolBarKeyWordSearch object at $0219F058, 432 bytes long

strcore.cpp(118) : {22736} normal block at 0x021A0E50, 37 bytes long.

 Data: <            Sele> 01 00 00 00 18 00 00 00 18 00 00 00 53 65 6C 65

strcore.cpp(118) : {22735} normal block at 0x021A0DF8, 25 bytes long.

 Data: <             Ite> 02 00 00 00 0C 00 00 00 0C 00 00 00 20 49 74 65

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPCommandBar.cpp(200) : {22720} normal block at 0x021A0A78, 48 bytes long.

 Data: <     âJ_        > 00 07 1A 02 88 E2 4A 5F 00 00 00 00 00 00 00 00

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControls.cpp(51) : {22719} client block at 0x021A09F0, subtype 0, 68 bytes long.

a CXTPControls object at $021A09F0, 68 bytes long

strcore.cpp(118) : {22718} normal block at 0x021A0998, 23 bytes long.

 Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72




Posted By: prashant
Date Posted: 02 January 2009 at 12:33am
Hi Oleg,

Digging further in the issue...I got locations of leak in my code as follows:

IMPLEMENT_XTP_COMMANDBAR(CMVToolBarDateRange,TToolBar))

Where TToolBar is derived from:
CXTPToolBar

Code for adding various CJ controls is as follows:
CXTPControlButton* pButtonFind = (CXTPControlButton*)CXTPControlButton::CreateObject();

m_pWndCalTB->m_combobox = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();

What I am missing here?



Posted By: prashant
Date Posted: 05 January 2009 at 1:30am
Hi CJ Support team,
Any suggestion for the same?

Few More leak locations:
IMPLEMENT_XTP_COMMANDBAR(CMVToolBarPrimViewName,TToolBar)
IMPLEMENT_XTP_COMMANDBAR(CMVToolBarDateRange,TToolBar)
IMPLEMENT_XTP_COMMANDBAR(CMVToolBarItemPicker,TToolBar)
IMPLEMENT_XTP_COMMANDBAR(CMVToolBarKeyWordSearch,TToolBar)

C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPToolBar.cpp(247) : {15011} normal block at 0x0219E668, 80 bytes long.
Data: <L¤^ èã      ÍÍÍÍ> 4C A4 5E 01 E8 E3 19 02 00 00 00 00 CD CD CD CD
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPCommandBar.cpp(200) : {15010} normal block at 0x0219E5F0, 48 bytes long.
Data: <èã   âJ_        > E8 E3 19 02 88 E2 4A 5F 00 00 00 00 01 00 00 00
C:\Program Files\Codejock Software\MFC\Xtreme ToolkitPro v12.1.1\Source\CommandBars\XTPControls.cpp(51) : {15009} client block at 0x0219C858, subtype 0, 68 bytes long.
a CXTPControls object at $0219C858, 68 bytes long
strcore.cpp(118) : {15008} normal block at 0x0219A478, 23 bytes long.
Data: <            user> 01 00 00 00 0A 00 00 00 0A 00 00 00 75 73 65 72


Posted By: prashant
Date Posted: 05 January 2009 at 11:55pm
Hello CJ Suport team,

I stuck into memory leak problems, specially in Commandbars and CJ Controls (Combo, Edit and Button)

Please suggest some soulution. Thanks.


Posted By: prashant
Date Posted: 09 January 2009 at 1:27am
Hi,

Found the way out...

Problem with two consecutive calls to InitCommandBars();

If you are calling InitCommandBars(); in main frame then no need to call it again in Child frame.

Cheers



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