I know memory leak checking can sometimes have false positives. I'm wondering if this is one of them, or if I'm doing something wrong.
I turned on memory leak checking by adding
Code:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
Then calling
Code:
_CrtDumpMemoryLeaks();
in the App's constructor.
I traced the issue back to the contructor for a variable included in the app class. The variable is a class I declare in the project.
Code:
//Class declaration
#define NUM_MT_COLORS 16
struct clrTable
{
COLORREF clrCode;
CString clrName;
};
class CColorTable
{
public:
CColorTable();
~CColorTable();
clrTable m_ClrTable[NUM_MT_COLORS+1];
};
Code:
//The contructor
CColorTable::CColorTable()
{
m_ClrTable[0].clrCode = TT_BLACK;
m_ClrTable[0].clrName=_T("Black");
m_ClrTable[1].clrCode = TT_MAROON;
m_ClrTable[1].clrName=_T("Maroon");
m_ClrTable[2].clrCode = TT_DKGREEN;
m_ClrTable[2].clrName=_T("Dk Green");
m_ClrTable[3].clrCode = TT_BROWN;
m_ClrTable[3].clrName=_T("Brown");
m_ClrTable[4].clrCode = TT_DKBLUE;
m_ClrTable[4].clrName=_T("Dk Blue");
m_ClrTable[5].clrCode = TT_PURPLE;
m_ClrTable[5].clrName=_T("Purple");
m_ClrTable[6].clrCode = TT_AQUA;
m_ClrTable[6].clrName=_T("Aqua");
m_ClrTable[7].clrCode = TT_DKGREY;
m_ClrTable[7].clrName=_T("Dk Gray");
m_ClrTable[8].clrCode = TT_GREY;
m_ClrTable[8].clrName=_T("Gray");
m_ClrTable[9].clrCode = TT_RED;
m_ClrTable[9].clrName=_T("Red");
m_ClrTable[10].clrCode = TT_GREEN;
m_ClrTable[10].clrName=_T("Green");
m_ClrTable[11].clrCode = TT_YELLOW;
m_ClrTable[11].clrName=_T("Yellow");
m_ClrTable[12].clrCode = TT_BLUE;
m_ClrTable[12].clrName=_T("Blue");
m_ClrTable[13].clrCode = TT_VIOLET;
m_ClrTable[13].clrName=_T("Violet");
m_ClrTable[14].clrCode = TT_LTBLUE;
m_ClrTable[14].clrName=_T("Lt Blue");
m_ClrTable[15].clrCode = TT_WHITE;
m_ClrTable[15].clrName=_T("White");
m_ClrTable[16].clrCode = -1; //Initially undefined
m_ClrTable[16].clrName=_T("Custom");
}
I get a memory leak error for every instance where a CString is set. I tried moving this to the MainFrame just to see if there was something with this being in the app, and saw the same memory leak errors.
I didn't include the functions in this class that manipulate this table. I didn't put it in the document because this is a multi-doc application and this table is universal to the program.
Is this an example of a false positive in the memory leak checker, or did I do something wrong? If it's me, could someone enlighten me about what to do?
Thanks,
Bill