Why is memory I haven't initialized set to 0xCC
?
Setting the memory to 0xCC
will decrease performance, so there must be a reason for filling the memory with this byte.
Inside CRT: Debug Heap Management
When you compile a debug build of your program with Visual Studio and run it in debugger, you can see that the memory allocated or deallocated has funny values, such as...
0xCC When the code is compiled with the /GZ option, uninitialized variables are automatically assigned to this value (at byte level).
Magic Number on Wiki:
CCCCCCCC Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory
In Visual Studio CRT Source, \VC\crt\src\malloc.h
:
#define _ALLOCA_S_STACK_MARKER 0xCCCC
// ...
#undef _malloca
#define _malloca(size) \
__pragma(warning(suppress: 6255)) \
((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \
_MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_STACK_MARKER) : \
_MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE), _ALLOCA_S_HEAP_MARKER))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With