{"id":2771,"date":"2022-08-30T15:27:38","date_gmt":"2022-08-30T15:27:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/08\/questions-about-c-memory-allocation-and-delete-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:38","modified_gmt":"2022-08-30T15:27:38","slug":"questions-about-c-memory-allocation-and-delete-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/questions-about-c-memory-allocation-and-delete-collection-of-common-programming-errors\/","title":{"rendered":"Questions about C++ memory allocation and delete-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;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:<\/p>\n<pre>*** glibc detected *** \/home\/mossen\/workspace\/abbot\/Debug\/abbot: double free or corruption (out): 0xb7ec2158 ***<\/pre>\n<p>followed by what looks like a memory dump of some kind. I&#8217;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&#8217;s only one place in my code that attempts this delete. Here&#8217;s the wacky part: it does not occur in debug mode. The code in question:<\/p>\n<pre><code>\nTerrain::~Terrain()\n{\n    if (heightmap != NULL) \/\/ 'heightmap' is a Heightmap*\n    {\n        cout<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2014-02-08 16:04:24. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2771","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2771"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2771\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}