1

I am debuging with Visual Studio 2008. I allocate a large buffer (around 12MB) using

buf = new unsigned char[bigValue];

Later when I deallocate the buffer using delete[] buf;, I see "?? ?? ?? ??" values in the debug memory window. Usually I see "fe ee fe ee". Is there something going wrong with my memory management that I'm not seeing?

I found a couple of related questions:

Why I can only see “??” at any address before 0x70000

In Visual Studio C++, what are the memory allocation representations?

but they don't answer this question.

Community
  • 1
  • 1
Matthew
  • 1,264
  • 1
  • 11
  • 20
  • probably has to do with the memory being interpreted as an array of `char`s (aka a string). Thus the debugger might be trying to print clearly non-ascii values. – jpm Jun 29 '12 at 15:32
  • @jpm thanks, but I don't think that's it. Other (smaller) buffers show the "fe ee fe ee" values indicating freed heap allocations. – Matthew Jun 29 '12 at 15:34

1 Answers1

4

Usually, the ?? means that that part of the process address space is not mapped. That is, those addresses are no longer in use by the process. To observe this behavior directly, you can VirtualAlloc a block of memory, watch it in the Memory window, then VirtualFree it, releasing it back to the OS.

The 0xfe flag is a sentinel value with which the debug heap fills freed memory that is still owned by the heap. If you deallocate a very large block of memory, it is likely that it will be released back to the OS immediately, rather than being returned from the heap.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • Thanks @James, that makes sense. And goes along with the answer on the "Why I can only see “??” at any address before 0x70000" question I saw. – Matthew Jun 29 '12 at 15:48