在 Visual Studio C++ 中,内存分配表示是什么? [英] In Visual Studio C++, what are the memory allocation representations?

查看:27
本文介绍了在 Visual Studio C++ 中,内存分配表示是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 中,我们都有过baadf00d",在运行时检查 C++ 调试器中的变量时,我们都见过CC"和CD".

据我所知,CC"处于调试模式仅用于指示内存何时被 new() 或 alloc() 并未初始化.而CD"代表删除或释放的内存.我只在 RELEASE 版本中看到过baadf00d"(但我可能错了).

偶尔,我们会遇到解决内存泄漏、缓冲区溢出等问题的情况,而这些信息会派上用场.

有人愿意指出何时以及在何种模式下将内存设置为可识别的字节模式以进行调试吗?

解决方案

此链接有更多信息:

https://en.wikipedia.org/wiki/Magic_number_(programming)#调试值

<前>* 0xABABABAB : 被微软的 HeapAlloc() 用于在分配堆内存后标记无人区"保护字节* 0xABACADAFE : 启动到这个值以初始化所有空闲内存以捕获错误的指针* 0xBAADF00D : Microsoft 的 LocalAlloc(LMEM_FIXED) 用于标记未初始化分配的堆内存* 0xBADCAB1E:当与调试器的连接断开时,错误代码返回给 Microsoft eVC 调试器* 0xBEEFCACE : Microsoft .NET 用作资源文件中的幻数* 0xCCCCCCCC : Microsoft 的 C++ 调试运行时库用于标记未初始化的堆栈内存* 0xCDCDCDCD : Microsoft 的 C++ 调试运行时库用于标记未初始化的堆内存* 0xDDDDDDDD : 被微软的 C++ 调试堆用来标记释放的堆内存* 0xDEADDEAD :当用户手动启动崩溃时使用的 Microsoft Windows STOP 错误代码.* 0xFDFDFDFD : 被微软的C++调试堆用来标记分配堆内存前后的无人区"保护字节* 0xFEEEFEEE : 被微软的 HeapFree() 用来标记释放的堆内存

In Visual Studio, we've all had "baadf00d", have seen seen "CC" and "CD" when inspecting variables in the debugger in C++ during run-time.

From what I understand, "CC" is in DEBUG mode only to indicate when a memory has been new() or alloc() and unitilialized. While "CD" represents delete'd or free'd memory. I've only seen "baadf00d" in RELEASE build (but I may be wrong).

Once in a while, we get into a situation of tacking memory leaks, buffer overflows, etc and these kind of information comes in handy.

Would somebody be kind enough to point out when and in what modes the memory are set to recognizable byte patterns for debugging purpose?

解决方案

This link has more information:

https://en.wikipedia.org/wiki/Magic_number_(programming)#Debug_values

* 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
* 0xDDDDDDDD : Used by Microsoft's C++ debugging heap to mark freed 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

这篇关于在 Visual Studio C++ 中,内存分配表示是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆