.NET Framework 1.1 Performance Guidelines - Working Set

From Guidance Share

Jump to: navigation, search

- J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman

Reduce your working set.

A smaller working set produces better system performance. The working set of a program is the collection of those pages in the program's virtual address space that have recently been referenced. As the working set size increases, memory demand increases. Factors that govern the working set size include the number of loaded DLLs, the number of application domains in the process, the number of threads, and the amount of memory allocated by your process. When you design your application, review the following points:

  • For better application startup time, load only the assemblies you need.
  • Consider assemblies that are being loaded as side effects of the assemblies you need.
  • Delay application initialization, touch code, and data when requested by the user (pay for play).
  • Reduce the number of application domains or make assemblies shared (nonshared assemblies are loaded once per application domain), or both.
  • Reduce the number of threads. This is less critical, but it reduces the working set by eliminating each thread's stack, the thread-specific memory allocations, and whatever code is unique to that thread. This can especially be an issue if you expect multiple copies of your application to be running, such as a client application running on a terminal server system.
  • Experiment with NGen and non-NGen to determine which saves the largest number of working set pages. Note that an application that is completely natively compiled does not load Mscorjit.dll, which saves approximately 200 KB or more, depending on the cost of the compilations. Generally, you can expect NGen to improve the shareability of your application (fewer private pages) at the price of slightly less raw speed (< 5% slower). Frequently, the speed gains from being smaller more than offset speed lost from having shareable code. Smaller is often faster.


You can use the Vadump.exe tool to measure your application's working set size. For more information, see "Vadump.exe: Virtual Address Dump" at http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/vadump-o.asp.

Personal tools