Dave's Brain

Browse - Programming Tips - Why is my memory holding 0xbaadf00d ?

Date: 2017aug29
Product: MSVC
Language: C/C++

Q.  Why is my memory holding 0xbaadf00d ?

A.  In debug mode Microsoft Visual C++ fills heap memory with this.
eg:

class MyClass { DWORD dwHello; } main() { MyClass myclass = new MyClass(); // Allocate in the heap printf("%x\n", myclass.dwHello); }
The fix is to initialize class members in the constructors. More info http://www.davekb.com/search.php?target=0xcccccccc https://en.wikipedia.org/wiki/Magic_number_(programming)

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.