Essay sample library > Memory snapshot

Memory snapshot

2023-11-06 18:28:05

A memory snapshot represents the memory state of the captured profile application. It contains information about all loaded classes, all existing objects, and references between objects.

A snapshot can contain an array of field values ​​and primitive types (int, long, char, etc.). Read more

Memory snapshots are disabled by default as collecting memory data can affect the debug performance of native or mixed mode applications. To enable snapshots in native or mixed mode applications, start a debugging session (shortcut: F5). When the Diagnostic Tool window appears, select the Memory Usage tab and select Heap Configuration. An instance of the selected object appears in the snapshot of the upper pane of the Instances view. The Path to Root Object and Reference Objects pane shows the object referencing the selected instance and the type of instance reference selected. When the debugger stops where the snapshot was created, put the mouse over the Value cell and the object's value is displayed in the tooltip.

When debugging using the integrated memory usage diagnostic tool of the debugger, you will find memory leaks and inefficient memory. Using the Memory Usage tool, you can create one or more snapshots of managed memory and native memory heap to understand the impact of object type on memory usage. You can collect snapshots of .NET, native, or mixed mode (.NET and native) applications. You can collect memory snapshots at any time with the Memory Usage tool, but you can use the Visual Studio debugger to control the behavior of the application when investigating performance problems. Setting breakpoints, stepping, full interrupts, and other debugger operations can help you focus performance investigations on the most relevant code paths. Running these actions while the application is running will eliminate noise from uninteresting code and can greatly reduce the time required to diagnose the problem.

The snapshot is initially stored in the renderer process memory. When you click on the snapshot icon and display it, they are transferred to DevTools as needed. When the snapshot is loaded and parsed into DevTools, the number under the title of the snapshot is displayed and the total size of accessible JavaScript objects is displayed. The top entry is the "total" line. Display the constructor name and group all the objects created by this constructor. The number of object instances is displayed in the # column. The Shallow Size column indicates the shallow size sum of all objects created by a particular constructor. The Retention Size column shows the maximum retention size in the same set of objects.