Unable to delete in release build

Hi. I'm having problems deleting. I have this variable declared: char* unparsedData = new char[4];
When I delete the variable using: delete[] unparsedData; in the develper environment I have no problem doing so. But when I make a release version of the program the program crashes when I try to free the memory.

1
2
3
4
5
6
7
char* m_pUnparsedData = new char[4];	
while(!coordinateFile.eof())
{
    coordinateFile.read(m_pUnparsedData, 4);
    //and some other stuff
}
delete[] m_pUnparsedData;
Have you tried executing exactly that code without all the other stuff to make sure the problem is with delete? It seems ok to me.
closed account (jw6XoG1T)
same thing happened to me before. in my case what worked for me was i just restarted my IDE. save everything and try that
Are you absolutely sure every time that m_pUnparsedData has the same value (i.e. is pointing to the same location in memory) when you delete it as it was when you allocated it?

The debug build is probably a lot more forgiving of you stomping all over memory than the release build, and a crash on delete (or free or release or dealloc) often indicates that you're trying to delete (or free or release or dealloc) memory that isn't yours.
Last edited on
Topic archived. No new replies allowed.