2

At one point in my program I am calling GlobalFree() to release a memory buffer I allocated with GlobalAlloc() using GMEM_FIXED flag. There is nothing that could be locking this block. However, when I call GlobalFree() after referencing the data (and all of the internal data is still the same as it was), the program stops and says it has encountered a user breakpoint from code in the GlobalFree() code.

Any ideas what could cause this?

oldSkool
  • 1,212
  • 5
  • 14
  • 29

1 Answers1

3

The heap functions typically call DebugBreak() - which implements a user-breakpoint - when they detect that the heap structures have been damaged.

The implication is you have written past the end (or the beginning) of the allocated area.

Chris Becke
  • 34,244
  • 12
  • 79
  • 148
  • +1, I saw similar looking breakpoints when trying to deallocate pointers not equal to ones returned by the allocation function - http://stackoverflow.com/q/1913343/57428 – sharptooth Dec 13 '10 at 09:19