Telerik blogs

JustTrace now seamlessly integrates into Visual Studio to provide an unobtrusive development experience, but that’s not all we did for the Q1 2013 release. We also enhanced memory snapshots to provide more data to discover the cause of a memory leak.

Setting up the Example

I created a simple web application to show tweets, and it appears that memory consumption creeps up while it’s in operation. To find out why this is happening, I select the Memory Profiler button in the Visual Studio toolbar before running the application.

Memory profiler

The application starts as it normally does; JustTrace doesn’t interfere with my workflow. I then type my Twitter handle and get tweets.
 application screenshot

At this point, it’s crucial to get a snapshot for comparison. To do this, I go to the JustTrace Session tab in Visual Studio (open it from the JustTrace menu if it’s closed) and click Get Snapshot.

I want to repeat the actions I’m analyzing for the memory leak, so I return to the page and Get Tweets for another person. I then use the Kill & Get button in the JustTrace Session tab to get my final snapshot to compare to the previous. For more information on these selections, read the article or watch the video for Using the JustTrace Timeline.

The Snapshot

Since I’m comparing instances at two points in time, JustTrace takes me to the Type List Diff view. On this page, I can see whether the instance count and size grew or shrunk for each type. It turns out my suspicions of a leak were right, as calling the Get Tweets action twice doubled the count for Twitter.Tweet.


JustTrace will navigate to one of our new features when double-clicking the type or using the Instances button in the ribbon.

Instances Diff

Instances Diff view

The Instances Diff view provides granular detail for each instance of the type such as the size, retained size, age (garbage collection generation), and status. I want to know why the previous instances survived, and this requires more detail. Obtain this by double-clicking a surviving instance or by pressing the Root Paths button.

Root Path Improvements

Root Paths view

The Root Paths view is familiar, but we’ve added static field names. As it turns out, this information is necessary in this example, since the instance I chose earlier survived garbage collection due to a static dictionary. There could be a cache and release mechanism in place to prevent repeated requests to a remote server, but it’s definitely something I want to review in case it’s simply retaining all instances. Thanks to JustTrace, I now know where to look!


When a performing a certain action in my application, memory increased. Since it continued to increase each time I called the action, I suspected a memory leak. Using JustTrace, I was able to determine that the garbage collector was not collecting instances created during the action as a static field referenced a dictionary containing these instances.

Happy profiling, and let us know what you think of JustTrace in our Feedback Portal!

JustTrace banner

About the Author

Chris Eargle

is a Microsoft C# MVP with over a decade of experience designing and developing enterprise applications, and he runs the local .NET User Group: the Columbia Enterprise Developers Guild. He is a frequent guest of conferences and community events promoting best practices and new technologies. Chris is a native Carolinian; his family settled the Dutch Form region of South Carolina in 1752. He currently resides in Columbia with his wife, Binyue, his dog, Laika, and his three cats: Meeko, Tigger, and Sookie. Amazingly, they all get along... except for Meeko, who is by no means meek.


Comments are disabled in preview mode.