Print Page | Close Window

40 bytes 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=12502
Printed Date: 09 May 2024 at 10:42pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: 40 bytes memory leak
Posted By: jortola
Subject: 40 bytes memory leak
Date Posted: 22 October 2008 at 7:54am

CArray<CXTPTopLevelWndMsgNotifier::CLIENT_INFO,CXTPTopLevelWndMsgNotifier::CLIENT_INFO &>::SetSize

CArray<CXTPTopLevelWndMsgNotifier::CLIENT_INFO,CXTPTopLevelWndMsgNotifier::CLIENT_INFO &>::SetAtGrow

CArray<CXTPTopLevelWndMsgNotifier::CLIENT_INFO,CXTPTopLevelWndMsgNotifier::CLIENT_INFO &>::Add

\xtptoplevelwndmsgnotifier.cpp (86): CXTPTopLevelWndMsgNotifier::Advise

\xtpcalendarcontrol.cpp (190): CXTPCalendarControl::CXTPCalendarControl

vld memory profiler informed about 40 bytes memory leak in this trace... is there any "fast" way to solve this?
 
Thx.
 



Replies:
Posted By: Oleg
Date Posted: 23 October 2008 at 5:41am
Hi,
What Visual Studio IDE show ?


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


Posted By: jortola
Date Posted: 23 October 2008 at 10:35am

VS8 + SP1 (2005)



Posted By: Oleg
Date Posted: 24 October 2008 at 1:48am
I mean does IDE show leaks ?

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


Posted By: jortola
Date Posted: 29 October 2008 at 10:24am

Yes, the IDE shows and 'unknown' leak, and the memory profiler indicates that that leak is produced from calendar.



Posted By: Oleg
Date Posted: 29 October 2008 at 4:08pm
Last question -  do you see same after run our sample ?

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


Posted By: jortola
Date Posted: 31 October 2008 at 4:33am
Nop, but the main difference between your sample and my app is that in your sample you use MDI (or SDI) and I dont embebe the calendar control in any window because I'm just using the sheduler part (OnReminders). So I derive a class from your CXTPCalendarControl class and just declare a object of this class.


Posted By: Oleg
Date Posted: 31 October 2008 at 9:07am
Hi,
Can you attach sample to show it ?


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


Posted By: jortola
Date Posted: 04 November 2008 at 2:17am
Sorry for the long sheet of code.
 
 
//File CCalendar.h

class CCalendar : public CXTPCalendarControl
{
public:
 CCalendar();
 virtual ~CCalendar();
 DECLARE_DYNCREATE(CCalendar);
 bool StartSchedule();
    ...
protected:
 DECLARE_XTP_SINK(CCalendar, m_Sink);
 void OnReminders(XTP_NOTIFY_CODE Event, WPARAM wParam , LPARAM lParam);
 ...
};

//File CCalendar.cpp
IMPLEMENT_DYNCREATE(CCalendar, CXTPCalendarControlView)

void CCalendar::OnReminders(XTP_NOTIFY_CODE Event, WPARAM wParam , LPARAM lParam)
{
 UNREFERENCED_PARAMETER(lParam);

 int eAction = (int)wParam;

 switch (eAction)
 {
 case xtpCalendarRemindersFire:
  {
   CXTPCalendarRemindersManager *calRemindersManager = GetRemindersManager();
   CXTPCalendarReminders calRemindersL;
   CXTPCalendarReminder *pcalReminder;
   CXTPCalendarEventPtr cEvent;
   XTP_CALENDAR_RECURRENCE_OPTIONS cOptions;

   calRemindersManager->GetActiveReminders(calRemindersL);

   for (int i = 0; i < calRemindersL.GetCount(); i++)
   {
    pcalReminder = calRemindersL.GetAt(i);
    cEvent = pcalReminder->GetEvent();
    //get some event atributes
    pcalReminder->Dismiss();
   }
   ::SendMessage(parentInstance, WM_CAL_SHEDULER, 0, 0);
  }
  break;
 case xtpCalendarReminderDismissed:
 case xtpCalendarReminderDismissedAll:
 case xtpCalendarRemindersMonitoringStarted:
 case xtpCalendarRemindersMonitoringStopped:
 default:
     break;
 }
}


bool CCalendar::StartSchedule()
{
 CXTPCalendarData* data = GetDataProvider();
 CXTPCalendarEventsPtr cEvents = data->RetrieveDayEvents(COleDateTime::GetCurrentTime());
 CXTPCalendarEventPtr p;
 for (int i = 0; i < cEvents->GetCount(); i++)
 {
   p = cEvents->GetAt(i, TRUE);

  //get some events data
 }
 cEvents->RemoveAll();
 EnableReminders(true);
 ::SendMessage(parentInstance, WM_CAL_SHEDULER, 0, 0);
 CConfig::SetCalendar(true);
 return true;
}

//Main
CCalendar calendar;
calendar.StartSchedule();



Posted By: Oleg
Date Posted: 04 November 2008 at 5:49am
Hi,
 
Problem that CXTPCalendarControl has own sink and think its main reason.
 
Try change it to
 

class CCalendar

{
public:
  bool StartSchedule();
    ...
protected:
 DECLARE_XTP_SINK(CCalendar, m_Sink);
 void OnReminders(XTP_NOTIFY_CODE Event, WPARAM wParam , LPARAM lParam);
 ...
CXTPCalendarControl m_wndCalendar 

};


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


Posted By: jortola
Date Posted: 04 November 2008 at 6:15am
It worked perfect, no leaks, working correct. Thanks for your help oleg. Great job.
 
Mmm.. I've just realized that I'm in AX forums, not MFC. srry.



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