visual-studio Visual Studio 2008 - 显示堆
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/671068/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2008 - show heap
提问by pkolodziej
Is it possible to view the heap and stack during debugging?
是否可以在调试期间查看堆和堆栈?
回答by RobS
AFAIK, the main windows you'd want to use are the Locals (Ctrl+ Alt+ V, L) and Autos (Ctrl+ Alt+ V, L) windows which MSDN has as:
AFAIK,您要使用的主窗口是本地(Ctrl+ Alt+ V,L)和自动(Ctrl+ Alt+ V,L)窗口,其 MSDN 具有:
...and for the Stack there's the Call Stack window (Debug -> Windows -> Call Stack) or Ctl+ Alt+ C.
...和堆栈有调用堆栈窗口(调试- >窗口- >调用堆栈)或Ctl+ Alt+ C。
However, I get the feeling this isn't what you're after.
但是,我感觉这不是您想要的。
If you are looking for an "in-memory" view you might be able to make use of Visual Studio's Memory windows which can be accessed from the Debug -> Windows -> Memory -> Memory x menus (where x is 1-4) or Ctrl+ Alt+ M, 1-4.
如果您正在寻找“内存中”视图,您可以使用 Visual Studio 的内存窗口,可以从 Debug -> Windows -> Memory -> Memory x 菜单(其中 x 为 1-4)访问或Ctrl+ Alt+ M, 1-4。
As a few people have now mentioned, there are a couple of other external tools which are quite useful for memory debugging (I use mainly SysInternals tools and the Debugging Tools for Windows).
正如一些人现在提到的,还有一些其他外部工具对于内存调试非常有用(我主要使用 SysInternals 工具和 Windows 调试工具)。
回答by kervin
You need the "Call Stack Window"... http://msdn.microsoft.com/en-us/library/a3694ts5.aspx
您需要“调用堆栈窗口”... http://msdn.microsoft.com/en-us/library/a3694ts5.aspx
By using the Call Stack window, you can view the function or procedure calls that are currently on the stack.
通过使用“调用堆栈”窗口,您可以查看当前在堆栈上的函数或过程调用。
And for the Heap, the "Memory Window"... http://msdn.microsoft.com/en-us/library/s3aw423e(VS.80).aspx
对于堆,“内存窗口”... http://msdn.microsoft.com/en-us/library/s3aw423e(VS.80).aspx
The Memory window provides a view into the memory space used by your application.
“内存”窗口提供了应用程序使用的内存空间的视图。
"Restoring Hidden Debugger Commands" may also be useful... http://msdn.microsoft.com/en-us/library/9k643651(VS.80).aspx
“恢复隐藏的调试器命令”也可能有用... http://msdn.microsoft.com/en-us/library/9k643651(VS.80).aspx
As you get into debugging memory, other debuggers will be more useful. As someone suggested, WinDbg is excellent for memory debugging. I use IDA Pro Disassembler a lot myself.
当您进入调试内存时,其他调试器会更有用。正如有人建议的那样,WinDbg 非常适合内存调试。我自己经常使用 IDA Pro Disassembler。
回答by Maxam
You can view the call stack while debugging, but I assume that's not what you're looking for. You might want to try Windbg and SOS, which are GREAT for debugging memory issues. A bit steep on the learning curve, but the payback is HUGE.
您可以在调试时查看调用堆栈,但我认为这不是您要查找的内容。您可能想尝试 Windbg 和 SOS,它们非常适合调试内存问题。学习曲线有点陡峭,但回报是巨大的。
回答by shoosh
If you actually want to look at the raw memory for some reason you can open the "Memory" debug window from "Debug->Windows->Memory" and write the address you want to look at in the edit box. You can also write in the edit box any expression which evaluates to an address and it'll show you that address, for instance &variable
如果您出于某种原因确实想查看原始内存,则可以从“ Debug->Windows->Memory”打开“内存”调试窗口,然后在编辑框中写入您要查看的地址。您还可以在编辑框中写入任何计算结果为地址的表达式,它会显示该地址,例如&variable
This is not very useful for actually looking at variables because you'll have a tough time parsing the raw bytes into meaningful values but it can be useful for debugging situations where you suspect there are buffer overruns or memory that is overwritten unexpectedly. It is particularly useful when used in conjunction with data-breakpoints.
这对于实际查看变量不是很有用,因为您将很难将原始字节解析为有意义的值,但它对于调试您怀疑存在缓冲区溢出或内存意外覆盖的情况很有用。当与data-breakpoints结合使用时,它特别有用。
回答by user2561639
I know this is an old question, but I figured I'd update it anyway...
我知道这是一个老问题,但我想无论如何我都会更新它......
Visual Studio 2015 comes with the Memory Usage Monitor built right in to the Diagnostic Tools panel. If you take snapshots before, during, and after what you want to inspect, you can retroactively peek at the heap view of those snapshots.
Visual Studio 2015 附带内置在诊断工具面板中的内存使用情况监视器。如果在要检查的内容之前、期间和之后拍摄快照,则可以追溯查看这些快照的堆视图。
Hope this helps someone.
希望这可以帮助某人。

