I have hit a bit of a wall with some debugging. I have been getting two Access violation errors in completely unrelated parts of my program, neither of them I really understand. One of them occurs when I declare a new variable, in this case,
std::map<float, float> fMap;
I have checked that the name is not used anywhere else in the code, I’m not sure how that would be relevant but it’s all I can think of. I think I have only ever managed to produce one of these when I do something stupid with a pointer. Does anyone have any ideas of what could be causing this? The project is being compiled with Borland 6.
Thanks,
The error has nothing to do with the declaration at hand: most likely, it is a delayed consequence of error that you made earlier. Some of the code that ran prior to hitting the map declaration has corrupted the heap in one way or another. Things that could potentially lead to a “delayed” crash are
These errors may trigger a crash immediately, but they often do not: instead, a corrupted piece of some sensitive heap structure waits to be allocated to trigger a crash. When
std::mapallocates memory for its internals, it triggers the crash by requesting memory from a corrupted heap.The best way to find out is to use a memory profiling tool. It should pinpoint the error to you at the time it happens, letting you address the problem instead of chasing its consequence.