Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2008 - show heap

Is it possible to view the heap and stack during debugging?

like image 756
pkolodziej Avatar asked Mar 22 '09 14:03

pkolodziej


2 Answers

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:

  • The Locals window displays variables local to the current context or scope. Usually, this means the procedure or function you are currently executing. The debugger populates this window automatically. In Visual C#, when the Exception Assistant is disabled, the Locals window also displays a pseudovariable $exception whenever there is an active exception. You can expand the pseudovariable to see details of the exception.
  • The Autos window displays variables used in the current line of code and the preceding line of code. For native C++, the Autos window displays function return values as well. Like the Locals window, the Autos window is populated automatically by the debugger.

  • ...and for the Stack there's the Call Stack window (Debug -> Windows -> Call Stack) or 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.

    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).

    like image 144
    RobS Avatar answered Oct 28 '22 13:10

    RobS


    You need the "Call Stack Window"... 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

    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

    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.

    like image 21
    kervin Avatar answered Oct 28 '22 12:10

    kervin