I know that the OS will sometimes initialise memory with certain patterns such as 0xCD and 0xDD. What I want to know is when and why this happens.
When
Is this specific to the compiler used?
Do malloc/new and free/delete work in the same way with regard to this?
Is it platform specific?
Will it occur on other operating systems, such as Linux or VxWorks?
Why
My understanding is this only occurs in Win32 debug configuration, and it is used to detect memory overruns and to help the compiler catch exceptions.
Can you give any practical examples as to how this initialisation is useful?
I remember reading something (maybe in Code Complete 2) that it is good to initialise memory to a known pattern when allocating it, and certain patterns will trigger interrupts in Win32 which will result in exceptions showing in the debugger.
How portable is this?