A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.jetbrains.com/webstorm/help/v8-cpu-and-memory-profiling.html below:

V8 CPU and memory profiling

V8 CPU and memory profiling

With WebStorm, you can capture and analyze CPU profiles and heap snapshots for your Node.js applications using V8’s sample-based profiler.

You can also open and explore snapshots captured in Google Chrome DevTools for your client-side code.

Before you start CPU profiling

CPU profiling helps you get a better understanding of which parts of your code take up the most CPU time, and how your code is executed and optimized by the V8 JavaScript engine.

Node.js CPU profiling in WebStorm is based on the V8 built-in CPU profiler, which provides information about the execution of your code and the behavior of the JavaScript engine itself including garbage collection cycles, compilation and re-compilation, and code optimization.

The profiler takes snapshots at certain intervals that are called ticks. Measurements are made not only for the work of your code, but also for the activities performed by the engine itself, such as compilation, calls of system libraries, optimization, and garbage collection.

Enable CPU profiling

To invoke V8 CPU profiling on application start, you need to specify additional settings in the Node.js run configuration.

  1. Go to . Alternatively, select Edit Configurations from the Run widget on the toolbar.

    In the Edit Configurations dialog that opens, click the Add button () on the toolbar and select Node.js from the list.

  2. From the list, select the Node.js run configuration to activate CPU Profiling in or create a new configuration as described in Running and debugging Node.js.

  3. Switch to the V8 Profiling tab and select the Record CPU profiling info checkbox. In the Log folder field, specify the path to the folder where the recorded logs will be stored, log files are named isolate-<session number>.

Collect CPU profiling information
  1. Select the run configuration from the list on the main toolbar and click or select from the main menu.

  2. When the scenario that you need to profile is executed, stop the process by clicking on the toolbar.

Analyzing CPU profiling logs

When you stop your application, WebStorm automatically opens the V8 Profiling tool window and shows the collected profiling data in it. If the window is already open and shows the collected data for another session, WebStorm opens a new tab. Tabs that were opened automatically are named after the run configurations that control execution of the applications and collecting the profiling data.

To open and analyze some previously saved profiling data, go to (or press Ctrl+Shift+A), start typing V8, and select Analyze V8 Profiling Log from the list.

Then select the relevant V8 log file isolate-<session number>. WebStorm creates a separate tab with the name of the selected log file.

Based on the collected profiling data, WebStorm builds three call trees and displays each of them in a separate pane. With these call trees you can analyze the application execution from two different points of view: on the one hand, which calls were time-consuming ("heavy"), and on the other hand, "who called whom".

Understanding the metrics in the call trees

The call trees use the Total and Self metrics that present the number of ticks in a function or its ratio to the total execution time:

The Of Parent metric shows the ratio of the pure execution time of a function to the execution time of the function that called it (Parent).

V8 optimiser

In some cases, V8 can optimize your code. For more information, refer to Optimizing for V8.

Top Calls tree

The Top Calls pane lists the performed activities in the descending order sorted by the Self metrics. For each activity, its Total, Total%, and Self% metrics are shown. For each function call, WebStorm displays the name of the file, the line, and the column where the function is defined.

The diagram in the Overview pane shows distribution of Self time for calls with the Self% metrics above 1%.

Bottom-up tree

The Bottom-up tree is helpful if you encounter a heavy function and want to find out where it was called from.

The Bottom-up pane also lists the performed activities sorted in the descending order by the Self metrics. Unlike the Top Calls pane, the Bottom-up pane shows only the activities with the Total% metrics above 2 and the functions that called them.

Top-down tree

The Top-down pane shows the entire call hierarchy with the functions that are execution entry points shown at the top. For each activity, its Total, Total%, Self, and Self% metrics are shown. For each function call, WebStorm displays the name of the file, the line, and the column where the function is defined.

Navigate through the call trees Expand or collapse nodes

When WebStorm opens a tab for a profiling session, by default it expands the nodes with the heaviest calls. While exploring the trees, you may like to fold some of these nodes or expand other ones.

Filter out light calls

Do this to see only the calls that actually cause performance problems.

Save and compare profiling data Export call trees Analyzing the Flame Chart

Use the multicolor Flame Chart to find where the application paused and explore the calls that provoked these pauses.

The chart consists of four areas:

The bottom and the right-hand areas are synchronized: as you drag the slider in the bottom area through the timeline, the focus in the right-hand pane moves to the call that was performed at each moment.

Moreover, if you click a call in the bottom area, the slider moves to it automatically and the focus in the right-hand pane switches to the corresponding function, if necessary the list scrolls automatically. And vice versa, if you click an item in the list, WebStorm selects the corresponding call in the bottom area and drags the slider to it automatically:

Select fragments in the Timeline Navigate through the Flame Chart

From the calls in the right-hand area, you can jump to the source code of called functions, to the other panes of the tool window, and to the areas in the flame chart with specific metrics.

Memory profiling

Memory profiling lets you detect memory leaks and dynamic memory problems and locate the fragments of code that caused them.

Enable memory profiling

To invoke taking memory snapshots on application start, you need to specify additional settings in the Node.js run configuration.

  1. Go to . Alternatively, select Edit Configurations from the Run widget on the toolbar.

    In the Edit Configurations dialog that opens, click the Add button () on the toolbar and select Node.js from the list.

  2. From the list, choose the Node.js run configuration to activate CPU Profiling in or create a new configuration as described in Create a Node.js run/debug configuration.

  3. Switch to the V8 Profiling tab and select the Allow taking heap snapshots checkbox.

Collect memory profiling information
  1. Select the run configuration from the list on the main toolbar and click or select from the main menu.

  2. At any time during the application execution, click on the toolbar of the Run tool window.

  3. In the dialog that opens, specify the name for the snapshot and the path to the folder where it will be stored. To start analyzing the snapshot immediately, select the Open snapshot checkbox.

Analyzing memory snapshots

When you take a snapshot and choose to analyze it, WebStorm opens the V8 Heap tool window with the collected data. If the window is already open and shows the collected data for another session, WebStorm opens a new tab.

To open and analyze some previously saved memory profiling data, go to (or press Ctrl+Shift+A, start typing V8, and select Analyze V8 Heap Snapshot from the list.

Then select the relevant .heapsnapshot file. WebStorm creates a separate tab with the name of the selected file.

The tool window has three tabs that present the collected information from different points of views.

Each tab has a Details pane, which shows the path to the currently selected object from GC roots and the list of object’s retainers, that is, the objects that keep links to the selected object. Every heap snapshot has many “back” references and loops, so there are always many retainers for each object.

Mark objects with text labels

Labels help you differentiate objects and move from one to another without losing the context.

Navigate through snapshots Search through snapshots
  1. In the Containment tab, click on the toolbar.

  2. In the V8 Heap Search dialog that opens, specify the search pattern and the scope to search in. The available scopes are:

The search results are displayed in the Details pane, in a separate Occurrences of '<search pattern>' view. To have the search results shown grouped by the search scopes you specified, press the Group by Type toggle button on the toolbar.

When you open the dialog next time, it will show the settings from the previous search.

05 June 2025


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4