Can't find memory leak

Started by
12 comments, last by Infinity95 10 years, 10 months ago

Every Game::EntitiesPtrs.pop_back(); call leaks an entity if you didn't delete first. Maybe not oodles, but ClearEntities() certainly leaks.

Stephen M. Webb
Professional Free Software Developer

Advertisement

Clearentities only pops if the pointer is a Null pointer, meaning the object was already removed with delete! ClearEntities() shouldn't leak anything. I always delete the Entities before popping. Also i doubt that the Entity class only takes 16 bytes of memory for each instance.

"Errare humanum est, sed in errare perseverare diabolicum."

You're zeroing over constructed STL objects:
SecureZeroMemory(&this->entityData, sizeof(this->entityData));

You're zeroing over constructed STL objects:
SecureZeroMemory(&this->entityData, sizeof(this->entityData));

Thank you! That was the problem. I just manually set everything to default values now and the memory leak is gone. Thanks a lot for the help all!

"Errare humanum est, sed in errare perseverare diabolicum."

This topic is closed to new replies.

Advertisement