![]() |
Add-in memory leak
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 |
All times are GMT +1. The time now is 10:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com