memory leak in mapi?

memory leak in mapi?

Post by andre » Wed, 09 Jul 2003 05:03:43



i have a function which is counting the number of messages in a message
store (ie... sms inbox), but when there are a ton of sms's, i am taking a
huge memory hit.. in the range of 10's of k's.  following is an example of
the code marked with the location of the memory hit.  what am i doing wrong
here?

thanks!!

andrew

////////////////////////////////////////////////////////////////////////////
/////////////////
int GetMessageCount()
{
 int count = 0;
 HRESULT hr = 0;

 LPSRowSet pRows = NULL;
 LPMAPITABLE pContentsTable = NULL;

 enum
 {
  ePR_ENTRYID,
  ePR_MESSAGE_FLAGS,
  NUM_COLS
 };

 static SizedSPropTagArray(NUM_COLS, mailColumns) =
 {
  NUM_COLS,
  PR_ENTRYID,
  PR_MESSAGE_FLAGS
 };

 hr = folder->GetContentsTable(0, &pContentsTable);

 hr = pContentsTable->SetColumns((LPSPropTagArray)&mailColumns, 0);

// **** a huge memory leak here????? depending on number or messages in the
store****
 while((hr = pContentsTable->QueryRows(1, 0, &pRows)) == S_OK)
 {
  if(pRows->cRows == 0)
   break;

   for(UINT i = 0;  i  <  pRows->cRows;  i++)
     MAPIFreeBuffer(&pRows->aRow[i]);

  count++;
 }

end:

 if(pContentsTable!= NULL)
    {
        pContentsTable->Release();
        pContentsTable= NULL;
    }

    if(pRows!= NULL)
{
      for(UINT i = 0;  i  <  pRows->cRows;  i++)
         MAPIFreeBuffer(&pRows->aRow[i]);
    pRows = NULL;

Quote:}

 return count;
Quote:}

 
 
 

1. Memory leaks with MAPI calls?

I've developed a routine to check the Inbox folder on the Pocket PC
for mail messages, and I've got a memory leak. I believe I'm freeing
up all buffers, etc. (as noted in some example code I'm using as a
reference), but I still get some memory leaking.

Anyone else have this problem? Any possible solutions or workarounds?

Thanks!

ppcinfo

2. MUI - Linking dynamic list -> cycle

3. Memory leak in MAPI?

4. HELP with Hayes Accura 96 and PCAnywhere 5.0

5. Virtual Office Systems - MAPI class dangerous Memory leaks.

6. File Security

7. Memory leak (more than a leak)

8. Signal Icons in Solution Explorer

9. Memory allocation and memory leaking...

10. memory leak

11. $$$ HELP $$$ Which API can watching memory leak?

12. Pathetic unresolved memory leak/issues!!!!

13. Memory Leak in PPC 2002?