Hi. I'm having problems deleting. I have this variable declared: char* unparsedData = newchar[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 = newchar[4];
while(!coordinateFile.eof())
{
coordinateFile.read(m_pUnparsedData, 4);
//and some other stuff
}
delete[] m_pUnparsedData;
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.