I can't eliminate a memory leak : While looping through the Inbox 
Message list using GetFirst() .. GetNext()

I'm developing a Visual C++ application on NT Workstation 4.0

I tried using Purify to help debug this: it showed about a 500 byte leak
in GetNext() for every extra message beyond the 1st one (i.e., I get no
leaks when there's only 1 message in the inbox, but there seems to be a
leak for every call to GetNext() ).  The Task manager indicates a growth
of about 4K for every pass through the Inbox.
This is not acceptable for our operating conditions.

I have a while (messages) loop embedded in a forever loop.  I sleep a 
user-specified delay between every loop cycle.

My purpose for the forever loop is to continuously monitor the inbox for
messages which come from various sources at random times.

I also tried the code from Knowledge base article Q171429  with the same
result.  They use essentially the same logic, except they don't have the
forever loop.  I close all the CDO objects, but do not logout or
disconnect the MAPI session each pass.  Maybe I should do this
periodically?
==========================================================================
A modified excerpt from the KB Q171429  article:
  ....
      for (;;)
      {
          // Create pointer to the Inbox Folder
          FolderPtr pFolder = pSession->Inbox;

          // Create pointer to the Messages Collection
          MessagesPtr pMessages = pFolder->Messages;

          // Acquire pointer and set properties of the MessageFilter
          MessageFilterPtr pMsgFilt = pMessages->Filter;
          pMsgFilt->Unread = (bool)TRUE;

          // Get the first Message object after filter is applied
          pAMessage = pMessages->GetFirst();

          // Process contents of Folder
          while (pAMessage != NULL)
          {
              // Display Properties
              wprintf (L"%s::",
                      (const unsigned short *)
pAMessage->Subject.bstrVal);

              // Get next Message
              pAMessage = NULL;
              pAMessage = pMessages->GetNext();
          }

          cout << endl << flush;

          // Destroy the reference to the Inbox, Messages Collection,
          // MessageFilter, and Message then reaquire them
          pFolder = NULL;
          pMessages = NULL;
          pMsgFilt = NULL;
          pAMessage = NULL;

          cout << "Iteration #" << ++i << endl << flush;
          Sleep (5000);
      }
  ....
==========================================================================

Any ideas or insights would be greatly appreciated.  

Also, what's the syntax to set the TimeLast property in a MessageFilter,
in C++?  I don't believe this works:
     pMsgFltr->TimeLast = "12/25/00";

Thanks for any help,
Will

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

Reply via email to