EDN Admin
Well-known member
hello everyone, i came across this problem:
HEAP[core.exe]: HEAP: Free Heap block 3af2a8 modified at 3af2d0 after it was freed
Windows has triggered a breakpoint in core.exe.
This may be due to a corruption of the heap, and indicates a bug in core.exe or any of the DLLs it has loaded.
the problematic line is new Log(....);
the Log is a class i defined.
i maintain a std::vector as a history log to keep a record of every
step. also i maintain a bool type variable to enable the user to choose
wether or not to keep records.
so the code is something like this:
class Log
{
...
}
std::vector<Log *> history;
bool keepRecord=false;
void record(Log *theLog)
{
if(keepRecord)
{
history.push_back(theLog);
}
else
{
delete theLog; //if i comment this line, the code runs perfectly
}
}
and for every step,
void step()
{
//do something here
record(new Log()); //keep the record, this line cause the problem
}
the "new log()" will throw the exception, the debuger says that
HEAP[core.exe]: HEAP: Free Heap block 3af2a8 modified at 3af2d0 after it was freed
Windows has triggered a breakpoint in core.exe.
This may be due to a corruption of the heap, and indicates a bug in core.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
but i can not see any bug in my code.
if i comment the "delete theLog;" the code run perfectly, but apparently it will cause memory leak.
what should i do? memory leak but run perfectly, no memory leak but crash
View the full article
HEAP[core.exe]: HEAP: Free Heap block 3af2a8 modified at 3af2d0 after it was freed
Windows has triggered a breakpoint in core.exe.
This may be due to a corruption of the heap, and indicates a bug in core.exe or any of the DLLs it has loaded.
the problematic line is new Log(....);
the Log is a class i defined.
i maintain a std::vector as a history log to keep a record of every
step. also i maintain a bool type variable to enable the user to choose
wether or not to keep records.
so the code is something like this:
class Log
{
...
}
std::vector<Log *> history;
bool keepRecord=false;
void record(Log *theLog)
{
if(keepRecord)
{
history.push_back(theLog);
}
else
{
delete theLog; //if i comment this line, the code runs perfectly
}
}
and for every step,
void step()
{
//do something here
record(new Log()); //keep the record, this line cause the problem
}
the "new log()" will throw the exception, the debuger says that
HEAP[core.exe]: HEAP: Free Heap block 3af2a8 modified at 3af2d0 after it was freed
Windows has triggered a breakpoint in core.exe.
This may be due to a corruption of the heap, and indicates a bug in core.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
but i can not see any bug in my code.
if i comment the "delete theLog;" the code run perfectly, but apparently it will cause memory leak.
what should i do? memory leak but run perfectly, no memory leak but crash
View the full article