Questions about C++ memory allocation and delete-Collection of common programming errors
I’m getting a bad error. When I call delete on an object at the top of an object hierarchy (hoping to the cause the deletion of its child objects), my progam quits and I get this:
*** glibc detected *** /home/mossen/workspace/abbot/Debug/abbot: double free or corruption (out): 0xb7ec2158 ***
followed by what looks like a memory dump of some kind. I’ve searched for this error and from what I gather it seems to occur when you attempt to delete memory that has already been deleted. Impossible as there’s only one place in my code that attempts this delete. Here’s the wacky part: it does not occur in debug mode. The code in question:
Terrain::~Terrain()
{
if (heightmap != NULL) // 'heightmap' is a Heightmap*
{
cout