Hello, I have an entity with a std::vector<Component*> m_components (Component is an abstract base class all other Components inherit from so I can polymorph them) and when I destroy the entity I clear the vector like so:
Entity::~Entity(){
for(std::vector<Component*>::iterator iter = m_components.begin(); iter != m_components.end(); ++iter){
delete *iter;
*iter = NULL;
}
m_components.clear();
m_components.shrink_to_fit();
}
and I get memory leaks. I looked online and everywhere I look it looks like I am doing it right. The memory leaks are a jumble of numbers:
Detected memory leaks!
Dumping objects ->
{377} normal block at 0x05804D28, 8 bytes long.
Data: < N > 90 4E 80 05 00 00 00 00
{376} normal block at 0x05804E80, 80 bytes long.
Data: < c w c > 90 B1 63 05 D8 81 77 05 90 B1 63 05 00 00 CD CD
{374} normal block at 0x05884028, 98304 bytes long.
Data: < > 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF FF
{373} normal block at 0x05804E38, 8 bytes long.
Data: < M > A4 4D 80 05 00 00 00 00
{372} normal block at 0x05804DF0, 8 bytes long.
Data: < M > 80 4D 80 05 00 00 00 00
{371} normal block at 0x05804D70, 68 bytes long.
Data: < c w c > C8 B0 63 05 C8 80 77 05 C8 B0 63 05 00 00 CD CD
{353} normal block at 0x05778268, 8 bytes long.
Data: < w > E8 81 77 05 00 00 00 00
{352} normal block at 0x057781D8, 80 bytes long.
Data: < c *x N > 90 B1 63 05 10 2A 78 05 80 4E 80 05 01 00 CD CD
{350} normal block at 0x057839A0, 262144 bytes long.
Data: < $ $ $ $ > 83 24 0C FF 83 24 0C FF 83 24 0C FF 83 24 0C FF
{349} normal block at 0x05778190, 8 bytes long.
Data: < w > FC 80 77 05 00 00 00 00
{348} normal block at 0x05778148, 8 bytes long.
Data: < w > D8 80 77 05 00 00 00 00
{347} normal block at 0x057780C8, 68 bytes long.
Data: < c x pM > C8 B0 63 05 08 19 78 05 70 4D 80 05 01 00 CD CD
{326} normal block at 0x05772908, 8 bytes long.
Data: < *x > 20 2A 78 05 00 00 00 00
{325} normal block at 0x05782A10, 80 bytes long.
Data: < &w c w > 18 26 77 05 90 B1 63 05 D8 81 77 05 01 00 CD CD
{323} normal block at 0x057819D0, 4096 bytes long.
Data: < > FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF
{322} normal block at 0x05781988, 8 bytes long.
Data: << x > 3C 19 78 05 00 00 00 00
{321} normal block at 0x05772950, 8 bytes long.
Data: < x > 18 19 78 05 00 00 00 00
{320} normal block at 0x05781908, 68 bytes long.
Data: <@"w c w > 40 22 77 05 C8 B0 63 05 C8 80 77 05 01 00 CD CD
{303} normal block at 0x0577A100, 8 bytes long.
Data: <(&w > 28 26 77 05 00 00 00 00
{302} normal block at 0x05772618, 80 bytes long.
Data: < c *x c > 90 B1 63 05 10 2A 78 05 90 B1 63 05 01 00 CD CD
{299} normal block at 0x05779030, 4096 bytes long.
Data: < > FF 00 00 FF FF 00 00 FF FF 00 00 FF FF 00 00 FF
{298} normal block at 0x05772308, 8 bytes long.
Data: <t"w > 74 22 77 05 00 00 00 00
{297} normal block at 0x057722C0, 8 bytes long.
Data: <P"w > 50 22 77 05 00 00 00 00
{296} normal block at 0x05772240, 68 bytes long.
Data: < c x c > C8 B0 63 05 08 19 78 05 C8 B0 63 05 01 00 CD CD
{275} normal block at 0x0563B220, 8 bytes long.
Data: <| c > 7C B0 63 05 00 00 00 00
{274} normal block at 0x0563B190, 80 bytes long.
Data: < &w *x N > 18 26 77 05 10 2A 78 05 80 4E 80 05 01 01 CD CD
{273} normal block at 0x0563B148, 8 bytes long.
Data: <p c > 70 B0 63 05 00 00 00 00
{272} normal block at 0x0563B0C8, 68 bytes long.
Data: <@"w x pM > 40 22 77 05 08 19 78 05 70 4D 80 05 01 01 CD CD
{271} normal block at 0x0563B070, 24 bytes long.
Data: <H c c c > 48 B1 63 05 C8 B0 63 05 04 00 00 00 20 B2 63 05
{171} normal block at 0x0357F378, 40 bytes long.
Data: < 5_ > D4 C5 35 5F 18 00 00 00 08 00 00 00 00 00 00 00
{170} normal block at 0x003FBFE8, 40 bytes long.
Data: < 5_ > D4 C5 35 5F 18 00 00 00 08 00 00 00 00 00 00 00
Object dump complete.
I am using VS2012's built in system for detecting memory leaks. This is the only place I am dynamically allocating anything in my program and when I comment out everything that has to do with the vector I get no errors. Thanks for any help.