PC Review


Reply
Thread Tools Rate Thread

Add-in memory leak

 
 
=?Utf-8?B?Q3VydCBKb2huc29u?=
Guest
Posts: n/a
 
      19th Nov 2007
I have an Excel 2003 Add-in, written in VC++ 6.0 using MFC that manages a
cache of information that must be reloaded if it changes. Using the
performance monitor I look at memory available and see that freeing the cache
does not release any memory and reloading the cache consumes memory,
depending on the size of the cache. Am I deleting the cache correctly? Look
at CCache::Clear(), below:

CCache::Load()
{
Clear();

for(/*Get each record from database...*/; /*...*/; /*...*/)
{
CCacheRecord * record = new CCacheRecord(/*...*/);
mapIntToRecord.SetAt(record->i, record);
}
}

CCache::Clear()
{
for(POSITION pos = mapIntToRecord.GetStartPosition(); pos != NULL; )
{
int i;
CCacheRecord * record;
mapIntToRecord.GetNextAssoc(pos, i, record);
delete record;
}
mapIntToRecord.RemoveAll();
}

CMap<int, int, CCacheRecord *, CCacheRecord *> mapIntToRecord;

class CCacheRecord
{
public:
CCacheRecord(/*...*/) { /* fill record from database */ }
private:
int i;
CString name;
...
}

Any help or suggestions would be useful.

Thanks,

Curt
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? DR Microsoft C# .NET 2 5th Feb 2008 02:52 AM
How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? DR Microsoft Dot NET 1 4th Feb 2008 11:43 PM
How to make MODI.Document not leak memory? I have millions of images to OCR but each time i OCR one it leaks memory. How to do the OCR and then clean up so that my app doesnt leak memory? DR Microsoft Dot NET Framework 1 4th Feb 2008 11:41 PM
Memory leak. Controls.Clear() doesn't free the memory. q23r Microsoft Dot NET Framework Forms 5 27th Jun 2006 02:08 PM
Memory Leak or memory paging problem with new Dell and XP Home SP2. Brian Windows XP Setup 1 13th Sep 2004 08:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:57 PM.