Category: Windows Tip

More Memory Leak Troubleshooting

Recently, I have been doing a lot of Memory troubleshooting.

Here are some windbg commands that helped:

Load the sos module (for .Net 4.0)

.loadby sos clr

List all of my object specific to my program:

!dumpheap -stat -type <parent namespace>

List all the instances of a particular object:

!dumpheap -type <namespace>.<object class name>

List references to the object:

!gcroot <address>

Break on garbage collection:

!findroots gen any

List references to the obect (must break in garbage collection):

!findroots <address>

Show sizes in the memory:

!eeheap

List large strings in memory:

!dumpheap -type System.String -min 10000

Then, I also found that you can use the SOS module with within Visual Studio.  First, in the project settings, I had to go to the Debug tab and check “Enable unmanaged code debugging” under “Enable Debuggers”.  Then, in the immediate window, I could run the following command:

.load sos

I thought my problem seemed to be related to the Data Grid view just like this forum post.  The post lists a code fix, but my problem is finding out where I place the code.  This blog mentions putting the code in the Form Close, but my problem is during the execution of the program.

Actually, it ended up being that I was loading a hidden column into the grid that was taking a lot of memory.  I had a Select * SQL statement, and I had to list only the fields that I wanted in memory.

Resources

UserPreferenceChangedEventHandler Resources

Memory Leak Troubleshooting

This is a tad off topic, but I don’t want to loose all of these reference links for tracking down memory leaks with a VB.Net program.

Here is the article that helped out a lot.
Rico Mariani’s Performance Tidbits: Tracking down managed memory leaks (how to find a GC leak)

As far as I can tell, you download the Vadump program from here:
Windows 2000 Resource Kit Tool: Vadump.exe

Since I have Visual Studio 2010 installed, I found it here:
<Visual Studio Home>\Common7\Tools\Bin\winnt

WinDbg, I didn’t find on my system. So, I had to download it in the Windows SDK from here:
Download and Install Debugging Tools for Windows

The CLR Profiler is another tool that I tried:
CLR Profiler

I haven’t finished, so maybe, I will have to write a follow up article.

Windows Update Tip

Yesterday, I was told of a great tip regarding Windows updates. I have had trouble many a time when Windows inadvertently rebooted while I left something to run overnight.

Step-by-Step: Windows Update – Disabling Auto-Restart for Automatic Updates

Here is a quick summary just in case the link goes away:

Open the group policy editor: Start > Run, gpedit.msc

Computer Configuration –> Administrative Templates –> Windows Components –> Windows Update

Enable the setting: No auto-restart for scheduled Automatic Updates installations

HCM9.0: Automatic Windows Login for VMWare

You would never want to do this in the corporate world, but with a test VMWare instance, it makes sense. I am already logging into the host machine, and so, why should I log into the VMWare machine again each time that I boot it.

So. I used the link below to have the machine automatically login when it boots:

How to turn on automatic logon in Windows XP

It did work for Windows Server 2003. I used the registry method, but I opened the dialog with the Start > Run … control userpasswords2, and it looked like it would have worked as well.

Windows Tip: Windows Activation

One of the problems with using virtual computers is that the hardware is virtual and somewhat easy to change, but the Windows registration is based on the hardware. Sometimes copying the WPA.DBL file can fix the problem.

I didn’t keep good notes on this, but I think the problem was caused the updating the Vmware tools in an image. After those changes, the activation screen displayed and I could not login. So, I copied the wpa.dbl file from an old copy of the Vmware Image and overwrote the file in the new image. After that, I never saw the activation screen again.

I tried this same approach when I attempted to migrate a Windows image to a VMWare image. It did not work that time, and I ran out of time to figure out why.

File Location: c:\windows\system32\wpa.dbl

Resources

Windows Tip of the Day: Avoid Re-Activate Windows XP After a Reinstallation

Windows Product Activation (WPA) for Windows XP

Windows Product Activation (WPA) on Windows XP