6

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.

Gangadhar
  • 1,893
  • 9
  • 9
Amaravathi
  • 115
  • 1
  • 2
  • 6
  • What operating system, compiler, and IDE are you using? – Robᵩ Apr 02 '12 at 17:07
  • What platform? Either way, do some googling or search SO, this question has been asked to death a million times. – Mahmoud Al-Qudsi Apr 02 '12 at 17:07
  • @Amaravathi Probably there is a double deletion in your program. With just the description, it is not possible to say where the problem is. Replicate the issue to a small program and post the code here. – Mahesh Apr 02 '12 at 17:07
  • On Windows, for free, to find memory related issues (leaks, in paticular) you can try Visual Leaks Detector: http://vld.codeplex.com/documentation – SChepurin Apr 02 '12 at 17:40

3 Answers3

7

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

On windows: see here.

Community
  • 1
  • 1
Gui13
  • 12,993
  • 17
  • 57
  • 104
0

With the information given, you'll have to step through all your code that you have added recently (if this is a recent issue) and evaluate and check each line and see if you are stomping memory. memcopy is a command that can cause this type of error if you're allocating to much for the size of the item you are copying.

Make sure you are only deleting your objects(pointers) once as well.

Wesley
  • 2,921
  • 6
  • 27
  • 30
0

If you are using windows, try winDbg. Its the best and very powerful.

barryjones
  • 2,149
  • 1
  • 17
  • 21