Memory Inspector: Inspect ArrayBuffer, TypedArray, DataView, and Wasm Memory.
The Memory Inspector panel is available from Chrome 91. You can check your version at chrome://version/
.
Use the new Memory inspector to inspect ArrayBuffer
, TypedArray
, and DataView
memory in JavaScript as well as WebAssembly.Memory
of Wasm applications written in C++.
Open the Memory Inspector
There are a few ways to open the Memory inspector.
Open from the menu
- Open DevTools.
- Click More Options > More tools > Memory inspector.
Open during debugging
Open a page with JavaScript
ArrayBuffer
. We will be using this demo page.Open the demo-js.js file in the Sources panel, set a breakpoint at line 18.
Refresh the page.
Expand the Scope section on the right Debugger pane.
You can open the Memory inspector:
- From the icon. Clicking on the icon next to the
buffer
property, or - From the context menu. Right click on the
buffer
property and select Reveal in Memory Inspector panel.
- From the icon. Clicking on the icon next to the
Inspect multiple objects
- You can inspect DataView or TypedArray as well. For example,
b2
is aTypedArray
. To inspect that, right click on theb2
property and select Reveal in Memory Inspector panel (No icon forTypedArray
orDataView
yet). - A new tab is opened in the Memory inspector. Please note that you can inspect multiple objects at once.
The Memory inspector
The Memory inspector consists of 3 main areas:
Navigation bar
- The address input shows the current byte address in hex format. You can input a new value to jump to a new location in the memory buffer. For example, try type
0x00000008
. - Memory buffers could be longer than a page. Instead of scrolling through, you can use the left and right button to navigate.
- The buttons on the left allow a forward/backward navigation.
- By default, the buffer is automatically updated on stepping. In the case it's not, the refresh button gives you the option to refresh the memory and update its contents.
Memory buffer
- From the left, the address is displayed in hex format.
- The memory is also shown in hex format, each byte separated by a space. The currently selected byte is highlighted. You can click on the byte or navigate with keyboard (left, right, up, down).
- An ASCII representation of the memory is shown on the right side. A highlight shows the corresponding value to the selected bits on the byte. Similar to memory, you can click on the byte or navigate with keyboard (left, right, up, down).
Value inspector
- A top toolbar features a button to switch between big and little endian and to open the settings. Open the settings to select which value types they want to see per default in the inspector.
- The main area shows all the value interpretations as per the settings. By default, all are shown.
- The encoding is clickable. You can switch between dec, hex, oct for integer and sci, dec for floats.
Inspecting memory
Let's inspect the memory together.
- Follow these steps to start the debugging.
- Change the address to
0x00000027
in the address input. - Observe the ASCII representation and the value interpretations. All values are empty at the moment.
- Notice the blue Jump to address button next to
Pointer 32-bit
andPointer 64-bit
. You can click on it to jump to the address. The buttons are grayed out and not clickable if the addresses are not valid. - Click on Resume script execution to step through the code.
- Notice the ASCII representation is now updated. All the value interpretations are updated as well.
- Let's customize the Value inspector to show only floating point. Click on the settings button and check only Float 32-bit and Float 64-bit.
- Let's change the encoding from
dec
tosci
. Notice the value representations are updated accordingly. - Try to navigate the memory buffer with your keyboard or using the navigation bar. Repeat step 4 to observe values changes.
WebAssembly memory inspection
The WebAssembly.Memory
object is an ArrayBuffer
that holds the raw bytes of object memory. The Memory Inspector panel lets you inspect such objects in Wasm applications written in C++.
To take full advantage of WebAssembly.Memory
inspection:
- Use Chrome 107 or later. Check your version at
chrome://version/
. - Install the C/C++ DevTools Support (DWARF) extension. This is a plugin for debugging C/C++ WebAssembly applications using DWARF debug information.
- Enable DWARF debugging in DevTools > Settings > Experiments > WebAssembly Debugging: Enable DWARF support and reload DevTools.
To inspect the WebAssembly.Memory
of an object:
In the Sources panel, open
demo-cpp.cc
and set a breakpoint in themain()
function at line 15:x[i] = n - i - 1;
.Reload the page to run the application. The debugger pauses at the breakpoint.
In the Debugger pane, expand Scope > Local.
Click the icon next to the
x: int[10]
array.Alternatively, right-click the array and select Reveal in Memory Inspector panel.
Starting from Chrome version 107, the Memory Inspector highlights all the bytes of a C/C++ memory object. This lets you tell them apart from the surrounding memory.
To stop highlighting object memory, in the Memory Inspector panel, hover over the object badge and click the x
button.
To learn more, see: