转自https://blog.csdn.net/chenlycly/article/details/23708049
转自https://blog.csdn.net/mxclxp/article/details/7524176
在写C++程序的时候,老实0xcdcdcdcd ,0xdddddddd ,0xfeeefeee ,0xcccccccc ,0xabababab这种提示,不知何解,google之,错误是这样产生。
0xcdcdcdcd - Created but not initialised
0xdddddddd - Deleted
0xfeeefeee - Freed memory set by NT's heap manager
0xcccccccc - Uninitialized locals in VC6 when you compile w/ /GZ
0xabababab - Memory following a block allocated by LocalAlloc()
VC++在Debug编译方式编译的程序中,会跟踪用new分配的内存。新分配的内存会用0xcd(助记词为Cleared Data)填充,防止未初始化;当它被delete后,又会被0xdd(Dead Data)填充,防止再次被使用。这样有利于调试内存错误。之所以选这样的填充模式,是因为:
1.大数,若被当成指针就会越界
2.奇数,指针通常指向偶数地址
3.非0,这样不会和 NULL 混淆。
在Release版中不会有这些字节填充。