Dave's Brain

Browse - Programming Tips - My heap is being corrupted somehow, how can I locate where?

Date: 2010apr21
Language: C/C++
Product: Borland C++ 5.x
Keywords: malloc, free

Q.  My heap is being corrupted somehow, how can I locate where?

A.  Sprinkle calls to heapcheck() around your code to narrow down the location.

Example from the help file:

#include <malloc.h> if (heapcheck() == _HEAPCORRUPT) { printf("Heap is corrupted.\n"); } else { printf("Heap is OK.\n"); }
There is also a _heapchk() function.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.