Performance tuning For .NET Applications

Performance tuning is one of the daunting task for making your applications run faster. There are several factors that can cause your application run slow. One of the factor is memory which can directly impact on your program execution. This post discusses the basics of memory optimization for .NET programs. If we outline the cases where memory access is bottleneck then it is easier for tune them. I also discuss the tools and strategies to determine the bottlenecks of memory in .NET Applications.



Memory Usage and Speed


Memory consumption is matter when your application manipulates the large amount of data. The speed is limited by how long it takes for CPU to bring the instructions from memory. More data then more time……


Memory consumption also matter is during an application startup. Hard disk access is much slower than main memory access. When the application launched second time then it will be faster, gaming computer desk.


Memory consumption matter is during application switching. When your application switches to the other applications , there is a chance of stealing the physical memory of your applications. When user returns to your application, these stolen pages needs to be fetched back from the desk, which makes your application very slow.


A feasible solution could be minimizing the amount of memory used. This reduces the load on the fast cache and makes program execution faster.

You can execute less code while program startup. Efficiently using the data structures. These things needs to be done in the early stages of the development.

Task Manager

You can use Task Manager to know how much of memory your application currently used. You can invoke it by (Winkey + R). If the columns don’t include PID, Memory-Working Set, use the View->Select Columns menu option to add them to the display.

Working Set is the physical memory currently being used by the process.

Application Size

Depending on memory usage application can be categorized small, medium or large. A simple and quick way to monitor memory usage and check for leaks is by running a test on your application. Run the application and monitor its working set usage; if the working set grows unbounded then it can mean a memory leak.

VADump: A More Detailed View

Task Manager just provides the summary of the memory usage of an application. To get more detail you need a tool called VADump. This can be invoked by typing VADump –sop processID in the command prompt under the directory in which it is installed. It prints a breakdown of memory within a single process down to DLL level. You can download the tool from here.

The .NET Garbage Collector

The .NET runtime supports automatic memory management. Garbage Collector in runtime finds memory that is no longer in use and reuses it for new allocations. Garbage Collector partitions the heap into three generations(0,1, and 2).


VADump gives the first level of breakdown of memory usage in the process. It does not tell you how much GC memory we are using and also whether we are having a healthy ration of GC generations. You can invoke it by typing PerfMon in run command. After PerfMon comes up, we need to configure it to display information about the GC. A healthy number for GC is less than 10 percent of total application time.


Memory issues are difficult to debug. If your application is large enough to care about memory, the key is to control memory usage in early stages of the development.

Source: MSDN magazine



Deepak Kamboj

Deepak Kamboj is a Solution Architect and Technology Enthusiast, located at Redmond, WA, having 14+ years of hands on experience in the IT industry.

You may also like...