BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

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

by Anand Narayanaswamy on Apr 19, 2013 |

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

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

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT