BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News .NET Memory Profiling in Visual Studio 2013

.NET Memory Profiling in Visual Studio 2013

Bookmarks

A common misconception is that .NET developers don’t have to worry about memory management. While it is true that memory is easier to deal with, there are still ways you can get into trouble.

The three most common mistakes made in .NET programming are:

  • Memory leaks, usually via delegates or event handlers that weren’t properly released.
  • Inefficient memory use, basically just holding onto more memory than necessary.
  • Unnecessary allocations, a subtle problem that can become quite expensive over time.

In the preview by Andrew B Hall, Visual Studio 2013 is shown capturing the status of an application running in a production setting. To do this you need a tool called ProcDump to create snapshots of the process’s memory. These dumps can then be loaded into Visual Studio for analysis.

Like other memory profiling tools, Visual Studio 2013 will list how many instances of each object were allocated and via what path they are rooted. (An object that is “rooted” is one that cannot be cleaned by the garbage collector because it is still accessible via a static field or local variable.)

Determining the cause of the memory leak is still left as an exercise for the developer. This makes Visual Studio inferior to the other products on the market. With the right filters, Red Gate’s ANTS Memory Profiler will flag objects that represent common mistakes like the aforementioned event handler based memory leaks. SciTech’s .NET Memory Profiler will even do one better. SciTech includes a summary with warning messages for the memory problems the tool is seeing.

SciTech also beats out Visual Studio 2013 and Red Gate in terms of the details available. Not only does it show you how an object is rooted, it will also show you the call path used to create the object in the first place. Also available are all of the fields on the object.

This is just a preview and more features may be announced in the future, but as it stands Microsoft is still a distant third in terms of .NET memory profiling.

Rate this Article

Adoption
Style

BT