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

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

问题描述

在Visual Studio中,我们都有baadf00d,在运行时检查C ++调试器中的变量时看到CC和CD。


$ b $根据我的理解,CC处于DEBUG模式,仅用于指示内存是new()还是alloc()并被单元化。而CD表示delete'd或free'd的内存。我在RELEASE构建中只看到baadf00d(但是我可能是错误的)。



一段时间以来,我们陷入了一个解决内存泄漏,缓冲区溢出等,这些信息就会派上用场。



有人可以指出什么时候和在什么模式下将内存设置为可识别的字节模式进行调试目的?

解决方案

此链接有更多信息:



http://en.wikipedia.org/wiki/Magic_number_(programming)

 
* 0xABABABAB:由Microsoft的HeapAlloc()用于在分配的堆内存后标记无人地保护字节
* 0xABADCAFE:启动该值初​​始化所有可用内存以捕获错误的指针
* 0xBAADF00D:由Microsoft的LocalAlloc(LMEM_FIXED)用于标记未初始化的分配的堆内存
* 0xBADCAB1E:错误代码当连接被切断到调试器时返回给Microsoft eVC调试器
* 0xBEEFCACE:由Microsoft .NET用作资源文件中的幻数
* 0xCCCCCCCC:由Microsoft的C ++调试运行库用于标记未初始化的堆栈内存
* 0xCDCDCDCD:由Microsoft的C ++调试运行时库用于标记未初始化的堆内存
* 0xDEADDEAD:用户手动启动崩溃时使用的Microsoft Windows STOP错误代码。
* 0xFDFDFDFD:由Microsoft的C ++调试堆用于在分配的堆内存之前和之后标记无人地保护字节
* 0xFEEEFEEE:由Microsoft的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:

http://en.wikipedia.org/wiki/Magic_number_(programming)

* 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

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

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