0xbaadf00d
What do 0xbaadf00d
, 0xdeadbeef
, and 0xcdcdcdcd
have in common?
They are hex codes that signal memory allocation state. When you use HeapAlloc with the debug heap (Windows), 0xbaadf00d
is written to memory you allocate. It lets you know you forgot to set it to something else, usually 0x00000000
. There are different codes for memory that has been deallocated, allocated but not initialized by other means, and more.
These are sentinel values (or magic numbers) that are helpful for a number of things, including debugging. Because they resemble words, they are easier for us to spot in memory inspectors and crash reports.
Check out this article on unusual memory bit patterns and the Wikipedia entry for “Hexspeak” for more patterns and their usage. They might provide some clues the next time you are debugging!