Visual Studio에서 C++/C# 를 개발할 때에 메모리를 직접 확인하는 경우가 있습나다.
그럴 경우 메모리에 있는 값의 의미를 정리해 보았습니다. 윈도우를 중심으로 정리했습니다.
* 0xABABABAB : HeapAlloc으로 메모리 할당만 하고 아직 사용하지 않는 경우 입니다.
* 0xCCCCCCCC : 초기화 되지 않은 스택 메모리입니다.
* 0xCDCDCDCD : 초기화 되지 않은 힙(Heap) 메모리 입니다.
* 0xBAADF00D : 힙(Heap)에 LocalAlloc(LMEM_FIXED)로 메모리 할당한후 초기화 하지 않은 경우입니다.
* 0xFDFDFDFD : Visual Studio 에서 디버깅 할 경우 힙(Heap)에 메모리를 할당한 후 잘못된 메모리 접근을 알기위해서 설정하는 가드(Guard) 값입니다.
* 0xFEEEFEEE : 힙(Heap)에서 메모리를 해제한 경우 설정되어 있는 값입니다.
프로그램 개발중 0xCCCCCCCC 이 값에서 오류가 생기면 초기화하고 값을 설정하지 않았다고 생각하시고 반대로 0xFEEEFEEE으로 오류가 발생하면 설정한 값을 미리 지우고 접근해서 오류가 생긴다고 생각하면 거의 맞을 것입니다.
<Visual Studio Memory View>
------------------------------------------------------------------------------------------------
* 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory * 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers * 0xBAADF00D : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory * 0xBADCAB1E : Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger * 0xBEEFCACE : Used by Microsoft .NET as a magic number in resource files * 0xCCCCCCCC : Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory * 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory * 0xDEADDEAD : A Microsoft Windows STOP Error code used when the user manually initiates the crash. * 0xFDFDFDFD : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory * 0xFEEEFEEE : Used by Microsoft's HeapFree() to mark freed heap memory
참고 URL