Collecting .NET Memory Allocation and Lifetime Data
This topic applies to:
Visual Studio Ultimate
Visual Studio Premium
Visual Studio Professional
Visual Studio Express
Visual Studio Profiling Tools support the collection of .NET memory allocation and object lifetime data, which helps you detect memory-related performance issues in your application.
Data about .NET memory allocation includes the size and number of .NET Framework memory objects that were allocated.
Object lifetime data includes the size and number of .NET Framework memory objects that were reclaimed in the three garbage collection generations.
You can collect data by using either the sampling or the instrumentation profiling method.
When you use the sampling method, the profiler tracks all .NET memory allocations and objects that are generated by the process that was started or attached to.
When you use the instrumentation method, the profiler tracks only those .NET memory allocations and objects that are generated by the instrumented modules.
When you are collecting .NET memory data (allocations, object lifetimes, or both) by using the sampling method, all user-specified sampling events are ignored, and the appropriate memory allocation events are used to collect data.
If you enable the profiling of.NET memory allocation, you also enable the Allocation View. If you enable the profiling of .NET lifetime data, you also enable the Objects Lifetime View. For more information, see .NET Memory Allocations View and Object Lifetime View.
For information about how to collect .NET memory data by using the Profiling Tools command-line tools, see Using .NET Memory Methods to Collect Memory Allocation and Object Lifetime Data in Using Profiling Methods to Collect Performance Data from the Command Line.
To collect .NET memory data
In Performance Explorer, right-click the performance session, and then click Properties.
On the Performance Session Property Pages dialog box, click the General tab, and select the Collect .NET object allocation information check box.
To collect .NET object lifetime data, select the Also collect .NET object lifetime information check box.
You can specify additional options in the Performance Session Property Pages dialog box of the performance session. To open this dialog box:
In Performance Explorer, right-click the performance session name, and then click Properties.
The tasks in the following table describe options that you can specify in the Performance Session Property Pages dialog box when you collect .NET memory data.
On the General page, specify naming details for the generated profiling data (.vsp) file.
On the Launch page, choose the application to start if you have multiple .exe projects in your code solution.
On the Tier Interaction page, add ADO.NET call data to the profiling run.
On the Windows Events page, specify one or more Event Tracing for Windows (ETW) events to collect with the sampling data.
On the Windows Counters page, specify one or more operating system performance counters to add to the profiling data as marks.
On the Advanced page, specify the version of the .NET Framework runtime to profile if your application modules use multiple versions. By default, the first version loaded is profiled.
The tasks in the following table are options in the Property Pages dialog box that are specific to profiling with the instrumentation method.
On the Binaries page, specify a location for the instrumented copies of the modules. By default, the original binaries are moved to a backup folder.
On the CPU Counters page, specify one or more processor performance counters to add to the profiling data.
On the Advanced page, specify any additional VSInstr.exe options that you want, such as options to include or exclude specific functions. For more information about VSInstr options, see VSInstr