At run time when I close my program I get the error: "crt detected that the application wrote to memory after end of heap buffer." I followed the program execution through a destructor to the deleter of the unique ptr and the error occured on the call to the deleter function. Another problem I want to mention is that for some reason the class defenition that the unique ptr is in requires that it has a public copy constructor. I tried to replicate these problems in another project with a different class and the same one, removing the copy constructor and destructor and changing the access labes. I couldn't replicate the same problems - the biggest difference between these two projects is the one with problems is a shared library, could this be the problem? Having to define the copy constructor although annoying and redundant I dont really care to much about, any speculations or advice on this memory error would be highly appreciated.
Asked
Active
Viewed 1,779 times
0
-
Post code, asking a list of questions makes it harder to answer. You can create multiple questions on the site though. :) – Tom Kerr Oct 14 '11 at 21:58
1 Answers
3
crt detected that the application wrote to memory after end of heap buffer.
Yes, this message appears when you call delete, but it's saying it found an error. Not caused one. Somewhere in your code, you are writing past the end of an array, and then during the delete, the memory manager found "footprints" in an out-of-bounds area.
Before each and every array access, put in :
assert(index<array_size);

Mooing Duck
- 64,318
- 19
- 100
- 158
-
-
Whoa, every time I post an answer like this the reply has always been "That's too much work!" An alternative is to use `std::vector` instead of naked arrays, and it should catch boundary errors for you. – Mooing Duck Oct 14 '11 at 23:27