Just started some testing of my resource manager and the CRT is reporting leaks but they are not being dumped at program termination. My program exits with code 0 and nothing is dumped.
So why would the CRT report memory leaks and yet none of them are dumped?
If I create the skysphere and sun CRT will report a mem leak on exit but no blocks are reported or dumped. If I only create the skysphere or the sun but not both, CRT does not report anything and as well no blocks are dumped.
Quite odd.
CResource.h
Code:
class IResource
{
public:
virtual IResource* Get()=0;
virtual void* GetBuffer() const=0;
virtual UINT GetSize() const=0;
virtual DWORD GetID() const=0;
virtual void SetID(const DWORD ID) const=0;
};
class CResource:public IResource
{
private:
CResource(const CResource &res);
CResource &operator=(const CResource &res);
protected:
//Size of file (and hence this resource)
UINT m_uFilesize;
//Resource unique ID - must be unique or system will fail
mutable DWORD m_dwID;
//Resource data
BYTE *m_pBuffer;
public:
CResource(std::string Filename);
virtual ~CResource()
{
//::MessageBox(0,"Deleting resource",0,0);
delete [] m_pBuffer;
}
...
...
};
CResMgr.h
Code:
...
...
class CResource;
//Typedef for cache list and map iterators
typedef std::list<CResource *>::iterator CacheList_Iter;
typedef std::map<DWORD,CacheList_Iter>::iterator CacheMap_Iter;
class CResMgr
{
private:
//Hide these two to prevent accidental copying
CResMgr(const CResMgr &);
CResMgr &operator=(const CResMgr &);
//Cache stats
DWORD m_dwDesiredSize;
DWORD m_dwCurSize;
DWORD m_dwNumHits;
DWORD m_dwNumMisses;
DWORD m_dwMaxSize;
protected:
//STL map and list
std::list<CResource *> CacheList;
std::map<DWORD, CacheList_Iter> CacheMap;
...
...
};
CResMgr.cpp
Code:
...
...
CResMgr::~CResMgr()
{
//Delete the list
CacheList_Iter List_Iter=CacheList.begin();
for (UINT i=0;i<static_cast<UINT>(CacheList.size());i++);
{
delete *List_Iter;
List_Iter++;
}
CacheList.clear();
CacheMap.clear();
}
Am I leaking in the destructor? I think I've posted all of the code needed to answer this.