Friday, February 27, 2009

Using pageheap.exe

I used pageheap today and it actually did what they told me it would do. Awesome! Why does MS have so many awesome tools that they don't tell us about and are rather arcane to find documentation on. Oh well.
How you use it :

1. Install Debugging tools for Windows. Add it to your path. It'll make your life a WHOLE LOT easier.
2. Type gflags.exe /p /enable yourapp.exe /debug WinDbg.exe
3. Run your app.
4. When youre done make sure to disable it  gflags.exe /p /disable yourapp.exe
5. You can check to see what you have page heap enabled by just typing  gflags.exe /p

Debugging Tools for Windows

Some pretty good debugging tools for windows can be found here.

Most importantly the use of umdh.exe to find memory leaks in your application.

Steps are pretty simple :

1. Install debugging tools.
2. Set gflags -i yourapp.exe +ust
3. Run app and find a good place to halt it where your baseline memory should be.

4. Get a heapdump of it. umdh -pn:yourapp.exe -f:first.log
5. Run the stuff where you want to find leaks for. Then return to where the baseline should be.
6. Get another dump. umdh -pn:yourapp.exe -f:second.log
7. Test the first dump against the second ump. umdh first.log second.log > compare.txt
8. Look at compare to see what still has allocations in the heap.
9. Look in second.log and find the Baseline that is in compare if there is any. You should be able to see the function that called the alloc/new. That's it.

Also not to be left out since I found this after writing this.

How to use pageheap.exe. This should help you find other things like, double free, overruns and underruns.

If you're willing to actually use a memory manager in your code. You can try Paul Nettle's MMGR.

And if all else fails, you could always try a commercial app like Memory Validator.


Thursday, February 26, 2009

VSPTree

I was bored. So here is what I made.

VSPTree is a graphical tool for the Visual Studio 2008 Standalone Profiler. It is named so because it gives you a tree view of the calltree generated from VSP files generated by the profiler.

Project page is Here.

Tuesday, February 24, 2009

Statistical Profiling for Free

1. Download the Profiler. Here .

2. Add the Profiler to the path.
- C:\Program Files\Visual Studio 9\Team Tools\Performance Tools.

3. Add the environment variable
- _NT_SYMBOL_PATH = symsrv*symsrv.dll*c:\localcache*http://msdl.microsoft.com/download/symbols

4. Run the application
- VsPerfCmd /start:sample /output:"FenixDebug.vsp" /launch:"FenixMultiDebug.exe"

5. When done testing. Exit the Application

6. Shutdown the profiler
- VsPerfCmd -shutdown

7. Generate the Report
- VsPerfReport /summary:all /packsymbols FenixDebug.vsp

8. Parse the reports. Easiest way is to use excel, but I might be working on a graphical tool soon.

CPU Profiling

If you ever wanted to know what eats all your CPU. Here.http://blogs.msdn.com/adioltean/archive/2004/12/21/329321.aspx