0

I'm starting out in C++ and using memcheck to check my programs for memory leaks.

If (when...) there are leaks, I get the Unfreed memory allocations remaining output, which the uses of new, malloc etc which haven't been freed. These are typically accompanied by the source file and line number of the allocation, which makes it easy to fix.

Sometimes though the source module is listed as unknown line:0, for calls to new in my case. If memcheck knows a call to new has been made, how is it that it can't tell where this has come from? I'm just trying to get my head around this so I can have some idea where these leaks might be coming from.

Wolf
  • 9,679
  • 7
  • 62
  • 108
rbennett485
  • 1,907
  • 15
  • 24

1 Answers1

0

I would suppose that it just couldn't resolve stack trace correctly. It happens with such tools (VLD, Deleaker etc.) when either they try to resolve stack trace in fast mode (e.g. reading EBP/ESP on x86) and frame pointers missed, or when they try to resolve stack trace using debugging information and this information is incorrect or just absent.

In most cases, stack trace can be resolved correctly. Sometimes - not.

Artem Razin
  • 1,234
  • 8
  • 22