BT

Your opinion matters! Please fill in the InfoQ Survey!

JavaScript Memory Analyzer in Visual Studio 2012 Identifies Leaks in Windows Store Apps

| by Anand Narayanaswamy  Followers on Apr 19, 2013. Estimated reading time: 2 minutes |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

Visual Studio 2012 Update 1 includes a JavaScript memory analysis tool for Windows 8 that enables developers to identify how much memory is being consumed by a JavaScript based Windows Store app and is available for Visual Studio 2012 Express, Professional, Premium and Ultimate on Windows 8.

The Launch startup project option in JavaScript memory tool enables developers to analyze the startup project in the current Visual Studio instance. The Launch installed App Package option launches the Windows Store app which enables Visual Studio 2012 to start the diagnostic session. The last option, Attach to running app prompts you to attach to the already running apps to enable Visual Studio to start the diagnostic session.

A process memory graph will be displayed when you launch the JavaScript memory tool that allows you to observe the amount of memory consumed by the app over time. The graph gives you an indication of the memory trend for the app which enables you to judge when it is appropriate to take a heap snapshot.

In order to inspect JavaScript memory, you have to make use of Take a Snapshot option, which generates a summary tile that indicates the size of the JavaScript heap at the time the snapshot was taken along with the number of objects allocated in addition to a screenshot of the application.

You can continue to capture snapshots at regular intervals and you can use the generated additional tiles for future comparison. Moreover, built-ins and objects IDs can be shown in the details table by using the drop down at the top right corner of the details view.

It is also possible to capture snapshots programmatically using console.takeHeapSnapshot, which takes a snapshot that appears on the tool and console.profileMark, which displays a profile mark in the memory graph while the diagnostic session is running including the ability to annotate the graph with custom marks.

Sometimes, you will be required to check for existence of the commands before usage, since they are only available in the context of the memory analyzer:

if (console && console.takeHeapSnapshot)
{
console.takeHeapSnapshot();
}

By default, the snapshots collection is saved to disk under a diagnostic sessions folder, which contains .diagsession files. It can then be renamed, shared across teams and can also be reopened in compatible versions of Visual Studio 2012. The snapshot tiles and the details views can be inspected upon opening the file.

Image Source - MSDN & Dr. Dobbs

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT