how to check memory corruption in C++

Amaravathi picture Amaravathi · Apr 2, 2012 · Viewed 13.9k times · Source

I have an issue in my project. Sometimes execution fails with the error "unabe to access a reading/writing location xxxxx". I know it is a memory corruption error. But how can I trace that error. It is failing at memory deallocation of a variable , if I comment that line it is processing fine. That is , the the memory for this variable has got released already. Earlier it was working fine, I added code recently but i didnt change anything related to this. How can I check the memory corruption fo this.

Answer

Gui13 picture Gui13 · Apr 2, 2012

Use valgrind if you're under linux, it will show you exactly what's happening if you stomp your memory.

On windows: see here.