Memory Monitor
A VS Code extension that shows how much memory each extension in the current window uses, and lets you restart the ones that grow too big.
VS Code runs extensions in a shared extension host, and many of them start their own processes: language servers, linters, tsserver. When one of them leaks memory, Activity Monitor only shows a row of identical "Code Helper (Plugin)" processes. Memory Monitor matches each of those processes to the extension that started it.
Features
Status bar: the total memory of this window's extension processes. It turns to a warning color above memoryMonitor.warnAboveGB. Click it to open the panel.
Explorer panel: one row per extension, sorted by memory. Example:
MEMORY MONITOR my-project
Pylance 2.4 GB · +1.6 GB in 3 h ↻
TypeScript server 980 MB ↻
Extension host 610 MB ↻
ESLint 240 MB ↻
Other: server.js 120 MB ✕
Hover a row to see its PIDs and full command lines. For the extension host, the tooltip lists the extensions that share it.
Growth: a row shows growth (+1.6 GB in 3 h) after its processes have been watched for 10 minutes, so memory used while starting up and indexing does not count. Growth below 50 MB is hidden. Time the Mac spends asleep does not count toward the 10 minutes.
Actions (the button on each row):
- Restart uses the extension's own restart command, when it has one: Pylance, the TypeScript server and ESLint.
- Restart Extension Host restarts every extension in the window, after you confirm.
- Kill sends
SIGTERM to the row's processes, after you confirm. Use it for extensions without a restart command. The extension may not start the process again until you reload the window.
The panel refreshes every 30 seconds while it is visible and every 2 minutes while it is hidden.
Requirements
- macOS. Memory is read with
ps and top. On other platforms the extension does nothing. In a Remote-SSH window the extension host runs on the remote machine, so the extension does nothing there either.
- VS Code 1.90 or later.
Settings
| Setting |
Default |
Description |
memoryMonitor.warnAboveGB |
3 |
The status bar turns to a warning color above this many GB. Display only; nothing is restarted. |
What is measured
The memory of the extension host and every process it started, as top reports it (the same "Memory" column as Activity Monitor). It does not include the window's renderer or the main VS Code process, so the total is lower than Activity Monitor's total for VS Code.
A process belongs to an extension when its command line contains that extension's install folder. A process that matches no extension belongs to the nearest parent process that does. A direct child of the host that matches nothing appears as Other.
Install
Install Memory Monitor from the Visual Studio Marketplace, or run:
code --install-extension HafizMuhammadShoaibSilat.memory-monitor
Or build it from source:
git clone https://github.com/hafizmuhammadshoaib/vscode-extension-memory-monitor.git
cd vscode-extension-memory-monitor
npm install
npm run package
code --install-extension memory-monitor-*.vsix
Development
npm install
npm run compile # build into out/
npm test # build, then run the tests with node --test
Press F5 in VS Code to open an Extension Development Host with the extension loaded.
src/core.ts holds the parsing, attribution and growth logic and does not import vscode, so the tests run on plain Node. test/fixtures/ holds real ps and top output. src/extension.ts holds the VS Code parts: the panel, the status bar and the actions.
License
MIT