Wednesday, January 17, 2007

Identifying Memory Leaks in .NET Apps

Applies to .NET 1.0, 1.1 and 2.0.

This information has been extracted from the MSDN article, Identify and Prevent Memory Leaks in Managed Code, by James Kovacs.

Useful PerfMon Counters

Process/[Private Bytes]
Reports all memory that is exclusively allocated for a process and can't be shared with other processes on the system.

.NET CLR Memory/[# Bytes in All Heaps]
Reports the combined total size of the Gen0, Gen1, Gen2 and large object heaps.

.NET LocksAndThreads/[# of current logical Threads]
Reports the number of logical threads in an AppDomain.

Interpreting the Results

The following problems may be identified:

  • Thread Stack Leaks - [# of current logical Threads] increases unexpectedly

  • Unmanaged Memory Leaks - [Private Bytes] increases but [# Bytes in All Heaps] remains stable

  • Managed Memory "Leaks" - [Private Bytes] increases AND [# Bytes in All Heaps] increases

For detailed explanations on these, please read the MSDN article, Identify and Prevent Memory Leaks in Managed Code.

Wednesday, January 03, 2007

Error Installing SQL Server 2005 Express

After trying to install SQL Server 2005 Express Edition on my machine, I got through almost the entire install before it failed with an error message:

The SQL Server service failed to start. For more information, see the SQL Server Books Online topics, "How to: View SQL Server 2005 Setup Log Files" and "Starting SQL Server Manually."

Argh!

If you get this, you should be able to do a quick fix and then click on Retry. Unlike me, who clicked on Cancel and then had to go through almost the entire setup process again!

Anyway, if you look in your log file, you should see something like the following:

Error Code: 1067
MSI (s) (4C!44) [09:42:09:089]: Product: Microsoft SQL Server 2005 Express Edition -- Error 29503. The SQL Server service failed to start. For more information, see the SQL Server Books Online topics, "How to: View SQL Server 2005 Setup Log Files" and "Starting SQL Server Manually."
The error is (1067) The process terminated unexpectedly.
.

Error 29503. The SQL Server service failed to start. For more information, see the SQL Server Books Online topics, "How to: View SQL Server 2005 Setup Log Files" and "Starting SQL Server Manually."
The error is (1067) The process terminated unexpectedly.

Microsoft has a KB article about a fix for a error on install, but when I read the expected symptoms, it didn't quite look like it was a match. However, following the workaround in this KB article will fix your problem. Well, it fixed mine anyway.

The article can be found here:
http://support.microsoft.com/default.aspx/kb/920114

Note: the article talks about a Protect folder that requires changes to its permissions, but this folder did not exist on my machine. Creating the folder first and then applying the permissions worked like a treat.