Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » Debugging   (RSS)

What is your computer doing with all that memory? Write your own memory browser

What is your computer doing with all that memory? There are various kinds of memory allocated and used in each process. These include: · Managed memory (VB.Net, C#, managed C++) · Heap memory · Stacks · Images (files loaded into a process) VirtualAlloc
Posted by Calvin_Hsia | 1 Comments
Filed under: , , , ,

Its easy to create a graph of memory use in Excel

In this post Examine .Net Memory Leaks I showed how to find a .Net managed memory leak. Now let’s create a graph of memory and resource use over time. Start Visual Studio 2008, File->New->Visual Basic (or C#) Windows, WPF application. Dbl click
Posted by Calvin_Hsia | 0 Comments
Filed under: , ,

Process Explorer and Process Monitor can help you understand a program

Process Explorer and Process Monitor are must-have free utilities that you can download from http://technet.microsoft.com/en-us/sysinternals/bb795533.aspx For example you can use ProcExp to examine a particular behavior of Visual Studio. Start Visual
Posted by Calvin_Hsia | 0 Comments

You can use Visual Studio to debug itself!

How do you find out why your computer or a running program is so slow? Here’s one way. Let’s attach the VS debugger to VS itself. The main executable for VS is devenv.exe. Start Visual Studio 2008. This will be the “debugger” Choose File->Open Project
Posted by Calvin_Hsia | 2 Comments
Filed under: , ,

Overload Operator new to detect memory leaks

There are various leak detection methods for memory allocators. A popular one is to tag each allocation with some information about the caller. When there’s a memory leak, you just need to look at that tag info to find the line of code that allocated
Posted by Calvin_Hsia | 5 Comments
Filed under: , ,

Write simple Debug helpers to help you debug and maintain your code

Much of my time is spent using the Visual Studio debugger examining code to figure out how it works and how to fix it. When stepping through a function, the values the function uses are very useful for code understanding. The debugger shows these values
Posted by Calvin_Hsia | 3 Comments

Make your code more maintainable: The evils of the Return statement

What does it mean to make code more maintainable? Certainly obfuscated code is hard to understand, by definition. A big part of maintainability is making it easier for others to read and understand what the code is doing. Your code may have been working

Examine .Net Memory Leaks

Writing programs using .Net is very productive. One reason is because much of memory management is “managed” for you. In C, C++ and other “native” languages, if you allocate memory, you’re responsible for freeing it. There were stopgap measures, like

Find the Executing function's name

Often I want to write the SAME code that will display the name of the currently executing method or function. That way I can just copy/paste the same code into multiple methods. For example, in sub Form1_Load I could put this line: System.Diagnostics.Debug.WriteLine(
Posted by Calvin_Hsia | 5 Comments

Customize the display of types in the Debugger using Extension Methods and DebuggerDisplay Attribute

I was writing some code using System.Text.StringBuilder . : Dim sb As New StringBuilder( "Init SB String" ) At a breakpoint the debugger Locals Window shows + sb {System.Text.StringBuilder} System.Text.StringBuilder If I expand by clicking on the "+",
Posted by Calvin_Hsia | 6 Comments
Filed under: , ,

Find which DLLs in your system are rebased

You can use CreateToolhelp32Snapshot and its family of functions to enumerate the running processes on your machine, including the modules loaded by each process My prior post ( DLL Image base addresses are the same in XP, different on Vista ) described

How to log application API calls using import module addresses

Let’s log all the calls that Excel makes to open or create a file. Start Visual Studio (any version), choose File->Open->Projects. In the dialog, change the “Files of Type” to “Executable Files (*.exe)” Choose any application like Excel: C:\Program

Customer question: what does the crash call stack mean

A customer asks: I read your article "Intentionally crash your program". I have some questions that I hope you can answer. When a fatal exception happens, foxpro display the calling stacks. How to read the calling stacks? A calling stack seems to contain

Dynamically attaching a debugger

Sometimes something goes wrong with your program and you want to investigate why. You can start Visual Studio, choose Debug->Attach to Process and choose the process you want to debug. (The dialog also allows remote debugging and choosing Native, Managed,
Posted by Calvin_Hsia | 4 Comments
Filed under: , ,

Problems reading and writing to the same file stream

I was helping a friend fix a problem that occurred in a VB.Net application. Upon inspection, an XML file was somehow invalid. The last few bytes were wrong. We found the code that modifies the file. It takes the original file, replaces a string with another
Posted by Calvin_Hsia | 1 Comments
Filed under: , ,
More Posts Next page »
 
Page view tracker