Introducing EAPs for dotTrace 6, dotCover 3, dotMemory 4.2

Please welcome a new ReSharper 9 EAP build that comes along with compatible dotTrace 6, dotCover 3 and dotMemory 4.2 Early Access builds.

Download the common .NET tools installer, launch it and choose the products you want to try.

We’ve done a great amount of work on the UI side, resulting in a more pleasant and easy-to-use profiling experience with dotTrace 6 EAP. A number of new features were also implemented, as well as the new and powerful timeline profiling option. Let’s have a look at what’s new.

dotTrace Home

When launching dotTrace 6, we’ll be presented with an all-new starting point: the dotTrace Home. From here, we can start a new local or remote profiling session for known .NET application types, attach to a running process and configure our profiling session.

dotTrace Home

Every application type will offer different settings for running the application we want to profile. Ticking the Advanced checkbox will provide us with additional options, such as using the profiler API.

If you’re new to performance profiling, check the Tutorials section on the home screen. We’ll guide you through how dotTrace works and how to analyze the data that was collected by the profiler.

Enhanced Profiling Controller

After launching a profiling session, we’ll see a new profiling controller open. We can use it to start the profiler, generate a snapshot, specify whether the profiler should continue capturing data or not, detach the profiler, or kill the running process.


With dotTrace 6 you can expand the profiling controller, providing you insight into the realtime CPU and memory usage of your application.

Profiler controller showing realtime CPU and memory usage

When our application runs multiple processes, we can select to profile any of them from the Processes page. Note that the Profile child processes option must be enabled for this to take effect.

Timeline Profiling

We’re introducing a new profiling type with dotTrace 6: Timeline profiling.

Timeline profiling collects temporal data about thread states, application events and other multi-threading data using Event Tracing for Windows (ETW). It comes in handy when analyzing multithreaded applications and lets us determine the cause of UI freezes, excessive garbage collections, uneven workload distribution, insufficient I/O and so on. The main advantage of Timeline profiling is that it not only allows us to see which calls were made by our application, but also how these calls were distributed over time.

Analyzing timeline profiling snapshots is similar to analyzing other profiling type results, with one difference: everything is bound to the timeline. We can view all events, or zoom in on a particular timespan of our application’s runtime and analyze the call tree, threads, memory allocation, garbage collection and I/O events.

Timeline profiling for multithreaded applications

In general, we can use timeline profiling all the time: just like the other profiling types it collects call stack data and allows us to determine performance bottlenecks. It is unable to determine the exact number of performed calls, making it less suitable to analyze algorithms, but that’s where tracing and line-by-line profiling are the tools of the trade.

Dissolved and Hidden Subsystems

When analyzing profiling results, we get a broad overview of subsystems used by our application. This gives us a hunch of where most time is spent: in the UI, in user code, with Garbage Collection, with I/O and so on. We can even define our own subsystems.

dotTrace subsystems view

From the options, dotTrace now lets us dissolve or hide subsystems. By default, each subsystem is visible as an entry in the subsystems pane. Making a subsystem dissolve will account the call times to its caller. Hidden subsystems will not be counted in results.

Subsystems now dissolvable or hidden

Setting these options for existing or new subsystems lets us slice and dice the profiling results in such a way that we only see the data we’re interested in.

Various UI Improvements in dotTrace 6 and dotCover 3

dotTrace 6 is now sharing a unified UI framework with ReSharper, dotCover and dotPeek. This brings an experience consistent to Visual Studio to the latest version of our profiler. All tabs and panes can be docked wherever we want, or detached from the main window so they float around. Very useful in multi-monitor setups! dotCover 3 receives a new UI for configuration settings dialog box.

Code Coverage in dotCover 3 on a Remote Machine

Code analysis in dotCover 3 can be performed on a remote machine. Set up a server and run it as a console application or Windows service on a remote machine. To perform code coverage, one needs to navigate to C:\Users\username\AppData\Local\JetBrains\Installations\dotCover01. Then, launch dotCover.RemoteCoverageServer.exe and connect to the server from the menu ReSharper -> Options -> dotCover -> Remote Coverage. In this scenario all the coverage tests are running on a remote server. This can save you a vast of performance resources on your local machine.

The Customary Trial Pitch

Give the latest versions of dotTrace 6 EAP, dotCover 3 EAP and dotMemory 4.2 EAP a try! Download the common .NET tools installer and choose products to install. Please note that doing so will remove all previous installations of ReSharper and other JetBrains .NET tools from Visual Studio, plus VS2005 and VS2008 are not supported so far.

All feedback, comments, issues and suggestions are welcome in dotTrace, dotCover and dotMemory issue trackers or through the comments below.

Posted in News and Events | Tagged , , , , , , , , , | 15 Comments

Another ReSharper 9 EAP build: now with ReSharper C++

We’ve already hinted before at the fact that ReSharper for C++ Early Access Program went public. In the second ReSharper 9 EAP build we’ve added dotPeek to the install bundle, and in this latest EAP, ReSharper for C++ is also available for installation. Now, we’ve already had several separate builds of R# with C++ support, so this post covers the new, never-before-seen features that are making their appearance in this EAP.

Important note: Please be aware that the C++ support in ReSharper will constitute a separate product rather than simply an add-on to the existing ReSharper features.

  • Extract Method — this refactoring lets you factor out a part of a complicated function into a separate function. Simply pick the part of code that you want to extract:
    Extract Method refactoring in ReSharper C++
    ReSharper will then let you pick the arguments of the extracted function:
    Extract Method refactoring in ReSharper C++
    … and make the appropriate adjustments:
    Extract Method refactoring in ReSharper C++
  • Type Hierarchy — this window shows you a tree representation of all the types in a particular inheritance hierarchy:
    Type Hierarchy window in ReSharper C++
  • Improved Code Completion — plenty of improvements here; for example, enum members taken from a different namespace are shown in code completion:
    Code Completion in ReSharper C++
    Or here’s another example. Say, you have a member function declaration. If you try to call it on the object, you’ll get the following completion list:
    Code Completion in ReSharper C++
    This is an example of generative completion — after you pick the top option, ReSharper will generate the following piece of code at the caret position:
    Code Completion in ReSharper C++
  • Typedef Substitutions let you leverage ReSharper’s power to perform in-place resolution on types and simplify them:
    Typedef Substitutions in ReSharper C++
  • Support for Calling Conventions — ReSharper now has proper handling of calling conventions and correctly recognizes usage scenarios, such as e.g. the use of Boost.Bind with BOOST_BIND_ENABLE_STDCALL
  • Improved Code Generation for Template Classes — for example, in this scenario
    Code Generation for Template Classes in ReSharper C++
    the code generator for the constructor of Y looks like this:
    Code Generation for Template Classes in ReSharper C++
    and the generated code for these options looks like this:
    Code Generation for Template Classes in ReSharper C++
  • Go to Declaration now works on variables declared with the auto keyword.
  • Improved Member Resolution with support for template types in some scenarios:
    Member Resolution in ReSharper C++
  • Memory Usage has been reduced by up to one third in some scenarios.

As you may have guessed, there are plenty of other improvements in ReSharper C++ EAP. So, if you’re interested in seeing all these features in action, you know what to do – grab the EAP and give them a go!

Note that apart from an updated ReSharper C++ EAP, the latest EAP build contains a set of fixes for ReSharper 9 EAP.

Posted in ReSharper Tips&Tricks | Tagged , , | 11 Comments

Regular Expression Support in ReSharper 9

If you’ve ever used regular expressions in practice, chances are you’ve been dismayed at their cryptic nature and frustrated by having to download a separate application just to make heads or tails of them.

Well, in ReSharper 9, we are adding support for regular expressions, helping you both read regular expressions and offering helpful diagnoses of potential problems.

Expression Highlighting

To make regular expressions more readable, ReSharper now uses different colors to highlight different parts of a regular expression.

Regular Expressions highlighting in ReSharper 9

We have introduced the following colors for different parts of regular expression syntax:

  • Light Blue — character classes, anchors and quantifiers.
  • Light Green — grouping constructs
  • Orange — set constructs
  • Pink and Light Pink — escape characters (these alternate for better readability)
  • Green — comments
  • Red — used to indicate errors

In addition to the color highlighting, we also highlight matching braces in groups, group names and sets:

Matching Braces for Regular Expressions in ReSharper 9

ReSharper is capable of highlighting invalid characters and escape character sequences, and also uses different highlightings for adjacent elements so as to make the expression more readable.

Error Highlighting

It wouldn’t be ReSharper if you couldn’t get analysis of your regular expressions, would it? That’s why, in ReSharper 9, regular expressions are checked and validated, and any errors are indicated in piecewise fashion: instead of just flagging the whole string as erroneous, ReSharper carefully highlights only the parts of the regular expression string that actually constitute an error:

Error highlighting for Regular Expressions in ReSharper 9

Some more examples of the kind of errors ReSharper can pick up on, including missing brackets or group names as well as invalid qualifiers that appear after an anchor character or a group name:

Missing Brackets highlighting in Regular Expression in ReSharper 9

Code Completion

ReSharper already provides plenty of context-sensitive code completion within string literals. For example, completion in ToString() function calls helps you enter format specifiers. So, with regular expressions, we did exactly the same thing by providing code completion for known regular expression escape sequences:

code completion for regular expressions in ReSharper 9

This form of completion is useful as a form of quick documentation, as in addition to the sequences themselves, ReSharper also shows textual descriptions.

As with other code elements, ReSharper provides the following completion mechanisms:

  • Basic completion shows elements that are available for the current scope
  • Smart completion shows the most relevant elements for the current scope
  • Double completion shows all possible elements
  • Automatic completion gets triggered after the user enters one of the \, ( or [ characters.

In addition to code completion within regular expressions, an additional benefit of ReSharper knowing about regular expressions is code completion for MatchResult objects: you now get explicit completion for group names within such a result:

Code completion for MatchResult objects in ReSharper 9

Naturally, you also get code completion within the group name string itself (i.e. Groups["<here>"]).

Escaping Quick-Fix Helper

Quite often, when you write a regular expression, you want to write something like the following:

Errors with backslash in regular expression

Regrettably, this will not compile since the backslash (\) characters themselves need to be escaped, making the sequences \w and \s invalid (as opposed to \\d, which is correctly escaped). To help with this, ReSharper provides a quick-fix that turns the string into a verbatim string:

Quick-fix to turn the string into a verbatim string in ReSharper 9

Notice that the \\d from the sample code has been turned into a \d. As always, ReSharper preserves the fidelity of the strings when changing the way they are presented.

Validation Utility

Having a separate little applet that validates regular expression is still very useful, which is why ReSharper is now providing one of its own:

Regular Expressions validation utility in ReSharper 9

As soon as the input text is modified, the standard .NET regular expression engine processes the expression and attempts to match it against the test input. All the located matches are highlighted in light green right in the text editor.

If there is a match, the exact match groups are indicated in the tree on the right of the window. The tree shows matches, groups in matches and all captures for groups (if there are more than two). Furthermore, if we select any element in the tree, the corresponding part of input text and the group (if any) of a regular expression are also highlighted.

Finally, the Check lines separately lets us test several input lines independently. This option becomes available only when there is more than one line in the input box, and test each of the single lines individually.

Finally, the typical regular expression match options are available from a drop-down check list:

Regular Expression match options in ReSharper 9

The validation utility provides quick documentation for each expression option: simply hover the mouse over a question mark next to the option and you’ll get a textual explanation of what this option does:

Quick Documentation in Validation utility in ReSharper 9

To make it easy and convenient to use the Validation Utility, ReSharper now offers a corresponding context action on all regular expression strings:

Conversion to Precompiled Expression

Quite often, we use a static Regex member (e.g., Regex.IsMatch()), for example:

Context Action on all regular expression strings in ReSharper 9

At some later point, we might want to turn this static call into an instance call, i.e., to precompile the expression and save the resulting finite state machine in a static field. Of course, this is only possible if the pattern does not depend on any input data.

Why would we want to do this? The reasons are obvious:

  • We want to reuse a regular expressions in other locations in our code; or
  • We want to use a great many regular expressions through static calls. According to Regex documentation, this class only caches a fixed number of expressions, the exact amount delineated by the Regex.CachedSize variable (default value is 15).

Thus, ReSharper provides a helper action called To precompiled regex that translates a static call into a precompiled regular expression. After invoking the action, we get the following:

To precompiled regex context action in ReSharper 9

Check it out!

So here it is: Regex support in ReSharper 9. To try it out right now, give ReSharper 9 EAP a go and let us know what you think!

Posted in ReSharper Tips&Tricks | Tagged , | 9 Comments

Introducing the ReSharper 9 Early Access Program

As many of you may have noted, there’s quite a lot of things happening in the land of .NET right now. The introduction of Roslyn and C# 6, the new ASP.NET, the forthcoming release of Visual Studio 14 and many other things are afoot and, once again, ReSharper is unrelenting in its support of the new and exciting language features and frameworks.

So today we are opening the Early Access Program (EAP) for ReSharper 9. What’s in store? Let’s take a look.

TL;DR VS 14 and C#6 support, regular expressions, lots of JS/TS improvements, more bulk fixes, a revised file layout editor, new navigation actions and a new shared platform for all our .NET-related tools.

C# 6 Support

ReSharper 9 supports the ?. operator in C# 6

We already did an introductory blog post on C# 6 support so, just to recap, here are some of the things that ReSharper 9 will be aware of:

  • Conditional access support — the .? operator lets us perform chained null checks (a.k.a the Maybe monad), so ReSharper is now not only aware of the construct, but is also capable of updating your null-checking code to the new paradigm.
  • Expression-bodied members — since the notation for simple expressions has been simplified in C# 6, ReSharper now offers the option to use expression bodies instead of curly-brace-delimited constructs. This is also a bulk action, so you can apply it across the whole project.
  • Auto-properties benefit from additional support of initializer expressions, as well as an ability to get rid of private setters and get truly immutable auto-properties.
  • Support for static usings (finally, you can type Sin instead of Math.Sin), exception filters and other new C# 6 constructs.

Bulk Actions and Fix in Scope

Fix in Scope: more quick-fixes that can be applied in the entire project or solutionReSharper 9 introduces further improvements to the Fix in Scope mechanic that allows bulk non-destructive changes on large areas of code. This includes the following:

  • Bulk Import ensures that when you import a chunk of code, ReSharper now goes through the code in your solution and generates the appropriate imports for all the necessary types and members – this includes extension methods as well.
  • Redundant Code Removal now appears as a separate item, so given a single redundant this. qualifier, you can fix these qualifiers locally or globally or you can remove all redundant code in a file, project or solution.
  • Global naming fixes help you rename code according to your conventions. Again, this is a bulk action, so you can fix a single location or a single file/project/solution within a single menu.
  • Move to File/Namespace now ensures that files with multiple class declarations get treated properly.
  • Remove Regions is another bulk action that will be particularly welcome by those of us who do not like the idea of regions in our code.

Navigation Improvements

Navigation improvements in ReSharper 9: Go to ActionSome of the navigation improvements in ReSharper 9 include:

  • Go to Action (a.k.a. Universal Alt+Enter) changes the Alt+Enter shortcut to provide top-level action suggestions as well as an ability to perform a text search for a particular action.
  • Navigate to Exposing APIs is a navigation option for finding all the methods that are capable of returning a particular type.
  • Assembly Explorer enjoys tighter integration, with dedicated Navigate To options both in the editor as well as the Solution Explorer.
  • The Go to Type mechanism has been disambiguated for generic types, so while on a variable of type List<Foo>, ReSharper will ask you whether you want to navigate to List<T> or Foo.
  • Find Usages now has a configurable setting for using the Preview Tab. It also no longer blocks the UI on long-running searches.
  • The Find Results window will no longer spawn extra tabs for the same type. And finally, it’s now possible to ignore or hide particular search results.

Code Style Settings

File Layout Editor in ReSharper 9

Style settings for C# include the following new features:

  • var Usage in Declarations has been split into three separate settings (for built-in types, simple types and elsewhere) for finer-grained control over how var-related highlights and quick-fixes function.
  • Instance member qualification determines precisely which members are qualified by the this. qualifier.
  • Static member qualification settings determine whether static members should be qualified via the current type or the type they are declared in.
  • All three aforementioned settings are also available as Code Cleanup profile elements.
  • Finally, a brand new GUI-based File Layout Editor — no more editing a cryptic XML file by hand!

Regular Expression Support

ReSharper 9 supports regular expressionsReSharper now understands regular expressions, so to make heads or tails of them, you might no longer need to have a separate application by your side. Here’s what it supports:

  • Syntax Highlighting for regular expressions, including piecewise highlighting of errors.
  • Code Completion helps you pick the wildcards for an expression. There is a special code completion feature for regular expression groups, too!
  • An Escaping Quick-Fix helps you quickly adjust wildcard backslashes to C# style by turning the string into a verbatim string.
  • A separate Validation Utility lets you quickly check input against a regular expression and get an immediate view of the matches and groups. As you might expect, the utility is highly configurable.
  • Options for Conversion to Precompiled Expressions let you optimize performance by turning ordinary regular expression invocations into static Regex instances.

TypeScript and JavaScript Improvements

ReSharper 9 improves TypeScript and JavaScript supportHere are some of the improvements introduced for the TypeScript language:

  • New Highlighting and Quick-Fixes now cover over 270 different types of errors.
  • New Refactorings include Introduce Field, Copy Type, Move Refactorings (move type to module/file, move into matching files, move to folder), Rename File as well as the Import of Types for Pasted Code.
  • Code Generation for TypeScript now supports implementing interfaces/generating missing members as well as generating constructors and overriding members, too.
  • Live Templates were improved to support two new scopes — Module Member and Type Member. ReSharper also comes with live templates for common TypeScript entities, such as classes, enums, interfaces and modules.
  • Parameter Info now supports not only function arguments, but generic arguments as well.
  • Specialized Signatures are now fully supported.

In addition, ReSharper also offers automated JavaScript to TypeScript conversion as well as initial support for ASP.NET vNext.

Unified Installer

We plan to offer a single unified installer for all our .NET products (ReSharper, dotTrace, dotMemory, dotCover, dotPeek). When installing, you will be able to pick which products you want, and the installer will do the rest. Also, behind the scenes, all our products now operate on a shared platform, which saves resources when several products are running at the same time.

Please note that the initial EAP build we’re posting will only offer installation of ReSharper itself; it will also remove all previous installations of ReSharper and other .NET tools, and will not support VS 2005 or 2008.

And a Few More…

Here are just a couple more features that were added or improved:

  • Visual Studio 14 support is here, as you would expect.
  • Switching features on and off has never been easier with a dedicated option page which lets you control which parts of your code ReSharper actually affects. Current options include support for Unit Testing, MsBuild and NAnt, CSS, JavaScript and TypeScript as well as Internationalization.
  • Debugging of decompiled code now works in ReSharper. Of course, you can also debug decompiled code using dotPeek.
  • ReSharper’s Architecture Tools now include an ability to generate a Type Dependency Graph. This form of visualization is great for finding out what code depends on a particular type, and what the type itself depends on. This diagram integrates with other ReSharper’s features, for example navigation result sets can now be shown as a Type Dependency Graph via the Alt+ shortcut.

This sums up what we have in store for the first EAP build but we’ll be adding more changes further on. We invite you to download ReSharper 9 EAP and give it a go!

Oh, and as always, let us know what you think and please report any issues you encounter — thanks!

Posted in ReSharper Tips&Tricks | Tagged , , | 36 Comments

ReSharper 8.2.3 Is Available

A new ReSharper maintenance release is now available. We recommend you to download and install ReSharper 8.2.3 in case you were unable to use previous bug-fix updates (8.2.1 and 8.2.2) due to expired subscription, although your subscription was valid for upgrading to 8.2 (expired after March, 21).

In addition to solving the upgrade issue, this update contains a fix to a problem with Go To Implementation on method or interface not working properly.

Stay tuned since more good news are just around the corner!

Get ReSharper

Posted in News and Events | Tagged , | 15 Comments

dotMemory 4.1 is Released: 6+ Reasons to Upgrade

Today we are thrilled to introduce dotMemory 4.1 with a new batch of .NET memory profiling goodies regarding automatic inspections, profiling process control, GC roots data, and more. Please welcome dotMemory 4.1, bringing you more rigorous, convenient and beautiful profiling experience.
dotMemory 4.1 splash screen

Why upgrade to dotMemory 4.1? For at least 6 reasons:

1: Disable/Enable collection allocations on the fly.
To profile certain functionality of your app without slowing down all of its other areas, try disabling allocations collection directly from the real-time profiling control view. For your convenience allocations collection period is marked by red line on a timeline.
Collection Allocations

2: Get more data on GC roots.
Starting from this update, dotMemory shows you the name of the field through which a static object is referenced. Later we plan to publish a good read on GC roots basics, so stay tuned.
Named static reference

3: Detect more common issues in a single click.
To help you focus on what really needs your attention, we’ve added a new automatic inspection that finds String duplicates and shows the related memory waste. Two more recently added automatic inspections, both related to WPF, were announced earlier in v4.0.10.
String duplicates inspection

4: Copy, save and share profiling results.
Simply press Ctrl+C to copy current analysis results to the clipboard. Selection and copying of multiple rows is supported for all “Type List” views, all nicely formatted and ready to be compared or shared.
Formatted copy of analysis results

5: Enjoy new restyled UI icons. Our notion of profiling is that it should be clear, productive and even beautiful. That’s why this update features new great-looking UI icons for your viewing pleasure.
Refreshed UI icons

6: Name your analysis. Easily order and manage multiple memory investigations by providing your analysis tabs with custom names. Never again get lost in loads of various unnamed analyses.
Custom analysis name

+: Even more reasons?
To get the full list of enhancement and fixes, please see the release notes.

Discover all new features introduced in dotMemory 4.1 in this short Overview Demo.

Download dotMemory 4.1 and try out all the new things shipped with this update. Learn more about dotMemory 4.1 on the What’s New page. A free trial version is available for 10 actual days of use (even if they are non-consecutive). Note for existing customers: To use this update, you will need an active subscription.

Feel free to share any feedback you may have. Ask questions on the discussion forum, report bugs and feature requests to our issue tracker and/or leave comments on this blog post below. Follow @dotMemory on twitter to stay tuned about state of the art in .NET memory profiling. And to raise your skills in spotting .NET memory issues with dotMemory, watch this series of video tutorials by Maarten Balliauw, JetBrains Technical Evangelist.

Profile with pleasure!
dotMemory team

Posted in dotMemory Tips&Tricks, News and Events | Tagged | 2 Comments

Introducing dotMemory Video Tutorials

Great news for .NET memory investigators, with the help from our technical evangelist Maarten Balliauw we have prepared a series of short videos that cover some of the core features of dotMemory.


These video tutorials should be a good starting point for users who are new to dotMemory and just starting to explore its functionality. It is focused around core features available in dotMemory, explained in short videos of 2-4 minutes each. You can learn basic concepts of .NET memory management, profiling workflow, analysis techniques and more.

32 minutes and 11 videos to watch:

Stay tuned! Subscribe to JetBrains YouTube channel and follow @dotMemory on Twitter to be notified when new videos arrived.

Maarten BalliauwMaarten Balliauw is a Technical Evangelist at JetBrains. His interests are all web: ASP.NET MVC, PHP and Windows Azure. He’s a Microsoft Most Valuable Professional (MVP) for Windows Azure and an ASPInsider. He has published many articles in both PHP and .NET literature such as MSDN magazine and PHP architect. Maarten is a frequent speaker at various national and international events such as MIX (Las Vegas), TechDays, DPC and others..

Enjoy the show!
dotMemory Team

Posted in dotMemory Tips&Tricks, How-To's | Tagged | 2 Comments

Get dotMemory 4.1 Beta

It’s been a while since dotMemory 4.0 was released, and we’ve spent all this time baking a new batch of .NET memory profiling goodies for you. Please welcome dotMemory 4.1 Beta, bringing you more rigorous, convenient and beautiful profiling experience.

Here are the must-try features in dotMemory 4.1 Beta:

Disable/Enable collection allocations on the fly. To profile certain functionality of your app without slowing down all of its other areas, try disabling allocations collection directly from the real-time profiling control view. Feel free to comment on DMRY-2317 in dotMemory issue tracker.
Collection allocations
Detect more common issues in a single click. To help you focus on what really needs your attention, we’ve added a new automatic inspection: String duplicates detects the issue and shows how much memory is wasted (DMRY-2232). Two more recently added automatic inspections, both related to WPF, were announced earlier in v4.0.10.
String duplicates inspection
Copy, save and share profiling results. Simply press Ctrl+C to copy current analysis results to the clipboard. Selection and copying of multiple rows is supported for all “Type List” views, all nicely formatted and ready to be compared or shared (DMRY-454).
Formatted copy of analysis results
Get more data on GC roots. Starting from this update, dotMemory shows you the name of the field through which a static object is referenced. (DMRY-774). Later we plan to publish a good read on GC roots basics, so stay tuned.
Named static reference
Enjoy restyled UI icons. Our notion of profiling is that it should be clear, productive and even beautiful. That’s why this update features new great-looking UI icons for your viewing pleasure.
Refreshed UI icons
Name your analysis. Easily order and manage multiple memory investigations by providing your analysis tabs with custom names. Never again get lost in loads of various unnamed analyses.
Custom analysis name

dotMemory 4.1 should be out in just a couple of weeks. For now, go ahead, download dotMemory 4.1 Beta and try on all the new things shipped with this update. Feel free to share any feedback you may have:

We’re eager to hear from you, and make dotMemory 4.1 better with your help and input.

Profile with pleasure!
The dotMemory Team

Posted in dotMemory Tips&Tricks, News and Events | Tagged , | 3 Comments

Fighting Common WPF Memory Leaks with dotMemory

When developing Windows Presentation Foundation (WPF), Silverlight and Windows Store applications, a number of common memory leaks may surface. In this blog post, we’ll see how dotMemory can help detect these common WPF memory leaks and how we can fix them.

Here are the leaks we will discuss in this post:

  • Binding leak
  • Collection binding leak
  • Textbox undo leak
  • Event Handler leak
  • x:Name leak

Binding leak

WPF comes with a number of data binding patterns, which, if we break them, can cause memory leaks in our applications. Take the following class:

Person class

When we bind to an instance’s Name property, the binding target starts listening for property change notifications. If the property is not a DependencyProperty or an object that implements  INotifyPropertyChanged, WPF will resort to subscribing to the ValueChanged event of the System.ComponentModel.PropertyDescriptor class to get notifications when the source object’s property value changes.

Why is this a problem? Well, since the runtime creates a reference to this PropertyDescriptor, which in turn references our source object, and the runtime will never know when to deallocate that initial reference (unless explicitly told), both the PropertyDescriptor as well as our source object will remain in memory.

How to detect it?

dotMemory comes with a series of automatic inspections, detecting common memory leaks. When profiling an application, we can instantiate the control which binds to our class and then dispose that control. When opening a snapshot in dotMemory, the snapshot overview page will tell us about WPF binding leaks immediately.

WPF analyze binding leak

This should be all we need to know, but let’s see if we can find proof of the theory above about the PropertyDescrriptor’s ValueChanged event handler keeping our objects in memory. After double-clicking the list entry, we can see the object set open. When we navigate to the Group by Similar Retention view, we get proof from the ValueChangedEventManager retaining our object:

Binding leak retention schema

How to fix it?

The simplest fix for a WPF binding leak would be making our Name property a DependencyProperty, or implementing the INotifyPropertyChanged interface correctly on our Person class and its Name property, like so:

Person class with INotifyPropertyChanged

If the object is of a type we can not edit, for example because it comes from a library we’re depending on, we can also explicitly clear the binding by calling:

Clear binding explicitly

Note that if a binding has the OneTime mode, this leak will not be present as the binding is done only once and the binding target will not listen for changes on the source object.

Collection binding leak

A similar issue to the WPF binding leak is the Collection binding leak. If there is binding to a collection that does not implement the INotifyCollectionChanged interface, WPF creates a strong reference to this collection. As a result, it stays in memory for the entire application lifetime.

How to detect it?

We will have to run our application and bind a control like a ListBox, for example, to our collection. Next, we can remove the binding by destroying the control and then taking a snapshot using dotMemory. We would expect our collection to be removed from memory, yet if we look at the snapshot overview we can see a WPF collection binding leak had been detected.

Detect WPF collection binding leak

If we then open the object set and look at the Group by Dominators view, we can see our collection is held in memory by the WPF DataBindEngine, an object which will be around for the lifetime of our application. And as long as our object dominator stays in memory, our collection will, too…

Analyse collection binding leak

How to fix it?

An easy way of fixing this issue is by implementing the INotifyCollectionChanged interface on our custom collection type. If the collection does not need any specific implementations, we could also inherit from the ObservableCollection type as it handles the implementation for us.


Textbox undo leak

One of the great things about WPF is that it enables Undo on several controls, like a textbox for example. For every change we make to its contents, WPF will keep the actions in memory so we can easily undo them using Ctrl+Z. Now imagine our application has a textbox in which lots of changes are being done… By default, the WPF UndoManager will keep up to 100 of these actions and in earlier WPF versions this limit was not there.

While not really a memory leak as such, having a high undo limit on textboxes in our applications may cause excessive memory usage without us evening knowing. And if we profile the application, we will see this as well.

How to detect it?

After running our application and making a large number of changes to a textbox’ contents, the dotMemory snapshot overview could show a large number of Char[] objects.

Largest Size diagram

If we drill deeper into this object set and look at the dominators (Group by Dominators), we can see that these object types are held in memory by several others. The first dominator here (TextTreeRootNode) is our textbox control itself. Of course it needs a few Char[] arrays to hold its contents. The second one however, UndoManager, is more interesting.


It seems the UndoManager is keeping on to quite a few Char[] arrays as well. Logical, as WPF’s undo behavior will need this information to be able to undo/redo changes made to the textbox.

How to fix it?

First of all, this is not really a leak. It’s a feature! It is important to know it’s there, though, for two reasons. The first one is when profiling WPF applications, we may see a number of Char[] arrays being created. Don’t get distracted by the UndoManager and try focusing on other dominators if the allocations are too excessive. Second, when building applications where a lot of text editing is done, high memory usage can be explained by this undo behavior.

To limit the number of entries the undo and redo stacks can hold, we can update the textbox’ UndoLimit property to a lower number. WPF used to default to –1 (unlimited) but in recent versions it defaults to 100.


We could also turn off undo entirely, by changing the IsUndoEnabled property.

Turn off undo

Event Handler leak

A common leak, not only in WPF but also in other frameworks, is the event handler leak. Event handler leaks are caused by developer oversight. Here’s an example. Imagine we open an AdWindow window in our application, and let it update its contents every few seconds. We could instantiate a DispatcherTimer in our constructor and subscript to the Tick event to handle these updates.

Subscribe to Timer

Now what happens if we close this AdWindow? It all depends… If we do nothing, the DispatcherTimer will keep on firing Tick events, and since we’re still subscribed to it, the ChangeAds event handler will be called. And if that event handler has to remain in memory for it to be called, our AdWindow will stay in memory too, even if we expected it to be released.

How to detect it?

There are a number of ways to detect this type of leak. The easiest is to capture a snapshot after the object was expected to be released. In the snapshot overview page, we will immediately see if the object remained in memory because of an event handler leak.

Event Handler leak

See our AdWindow there? dotMemory detected it is kept in memory because of an event handler leak. Now how to find out which event handler is keeping it in memory… If we double-click the entry, we will see the details of the instance. Under Key Retention Paths, we can easily identify which type’s event handler retains our object in memory: the DispatcherTimer.

Key Retention Paths

If we know our code base,we know where to look. But imagine this is the first time we see the code base, how do we know where we are subscribing to this event handler?

First of all, we want to make sure our snapshot was captured collecting creation stack traces (can be enabled in the profiler options). From the Key Retention Paths diagram, we can now double-click the EventHandler entry here, which will open the specific event handler instance. From the Creation Stack Trace view, we can see we’re subscribing the event handler in the AdWindow constructor.

Creation Stack Trace

The Shortest Paths to Roots Tree view will tell us which event we’re subscribing to.

Shortest Paths to Roots

How to fix it?

From the investigation above, we know which event and which event handler we’ve forgotten to unsubscribe from (DispatcherTimer’s Tick event), and where we’re subscribing to it in the first place (the AdWindow constructor).

Unsubscribing from the event in the constructor is pointless in this case, as it would render our functionality of rotating content every few seconds useless. A more logical place to unsubscribe is when closing the AdWindow:

Closing AdWindow

Note: The DispatcherTimer example here is a special case, as the above will still not ensure our AdWindow is released from memory. If we profile the application, we’d be able to see the AdWindow instance is still there. The Key Retention Paths diagram will help discover we have to set the private variable adTimer to null as well, to remove another reference from the .NET runtime’s DispatcherTimers collection. Or how one memory leak can hide another.

x:Name leak

The beauty of building UI’s in software is that we can do some nice things with it, like removing controls from the UI when a given action is performed. Depending on how we build our UI, we may be introducing a memory leak by doing this…

WPF creates a strong global reference to the UI element that is declared in XAML if it uses the x:Name directive.


Dynamically removing an element from code will not remove the control from memory… Not even if we remove it from the parent control’s Children collection.

Dynamically remove control

How to detect it?

After clicking he button that removes our control, we can capture a snapshot in dotMemory. The snapshot overview has an automatic inspection for x:Name leaks and will tell us our control remained in memory.

x:Name leak

We can drill down and look at the Key Retention Paths to see WPF is retaining our object in memory.

How to fix it?

To ensure the control gets removed from memory, we will have to call the UnregisterName method of the parent control. The code that removes our control from the window could be updated to look like this:


There are many more common memory leaks and things we can do to improve our applications. Check the Unusual Ways of Boosting up App Performance series we did earlier.

New automatic inspections on WPF collection binding and WPF x:Name were released with the latest v.4.0.10 update on September 2, 2014. Please note: To use dotMemory 4.0.10, your subscription should be valid until September 2, 2014. Otherwise, the subscription renewal is required.

If you are not using dotMemory yet, it’s a good time to start. Together with multiple enhancements, the minor update v4.0.10 introduces a new evaluation model: from now on you can use the trial version for 10 actual days of use, even if they are non-consecutive, even if your previous evaluation period is expired. Get the latest dotMemory and enjoy!

Posted in dotMemory Tips&Tricks, How-To's | Tagged , , | 1 Comment

ReSharper 8.2.2 with JetBrains Account Support is Here

A new ReSharper maintenance release is now available for download. Please install this upgrade if you have experienced the following issues with ReSharper 8.2:

  • A numeric comparison error when getting or updating nuget packages (when MSBuild is used to obtain project references).
  • SSL-Certificate error while connecting to JetBrains Account.

Speaking of JetBrains Account, this is a new way of managing your licenses for JetBrains tools. As a single interaction point with JetBrains products and services, it provides a simple and convenient way to access and manage your purchases, view your order history, distribute licenses to users, and more. You can use your JetBrains Account to have single access to the following JetBrains services:

You can still use your license key to activate and work with our tools if that way is more comfortable for you.

Additional Tools

Please note that along with ReSharper 8.2.2 you can download and install compatible builds of dotTrace, dotCover and dotMemory with similar fixes for the SSL-Certificate error.

By the way, great news for dotMemory users: we’ve added two brand new automatic inspections of common WPF memory leaks types. If you are not using dotMemory yet, today’s a good day to start. Together with multiple enhancements, the minor update v4.0.10 introduces a new evaluation model: from now on you can use the trial version for 10 actual days of use, even if they are non-consecutive. Enjoy!

Posted in News and Events | Tagged , , , , | 26 Comments