RAM Cache
A VS Code extension for Linux, macOS and Windows that shows the RAM of the machine VS Code
runs on. In a Remote-SSH window, that is the remote server. It shows what is using memory and
clears the operating system's file cache automatically at a threshold, without stopping any
program.
Install
- From the Marketplace: search for RAM Cache in the Extensions view.
- From a file: download the
.vsix, then run Extensions: Install from VSIX….
After installing, click the ram head icon in the Activity Bar. Run RAM: Set Up Cache Clearing once
so the cache can be cleared; it needs your administrator password one time.
macOS and Windows support is included, but so far it has only been tested on Linux.
Features
- Status bar:
RAM 22% · cache 36%. It turns yellow when RAM including cache is at or above
the auto-clear threshold, and red when programs themselves use more than the pressure-warning
threshold. Click it to open the dashboard.
- Dashboard (
RAM: Open Dashboard):
- Cards and a bar for memory used by programs, cache, and free memory.
- A live graph of the last 30 minutes, with the threshold line and markers where the cache was
cleared.
- What is using memory, in three views:
- by process (application, memory, PID, user, folder, command)
- by application (e.g. all VS Code processes added together)
- by folder (the workspace or directory each process works in; on Windows, the program's
folder)
- An End button for your own processes. It asks for confirmation first and is never shown
for VS Code or operating-system processes.
- Buttons to clear the RAM cache now and to turn auto clear on or off.
- Disk caches (pip, plus thumbnails on Linux) with their sizes and a button to clear each.
- A log of every action.
What "cache" means on each system
| OS |
Cache shown |
How it is cleared |
One-time setup |
| Linux |
page cache (free: buff/cache) |
sync; echo N > /proc/sys/vm/drop_caches (N = ram.autoClear.dropLevel, default 1) |
sudo password once |
| macOS |
"Cached Files" (as in Activity Monitor) |
/usr/sbin/purge |
sudo password once |
| Windows |
standby + modified lists (Task Manager: "Cached") |
empty the standby list |
one administrator (UAC) prompt |
Clearing the cache never stops or slows down a running program's memory. The OS only reads
some files from disk again afterwards.
| Term |
Meaning |
| Used by programs |
Memory programs really hold. Clearing the cache does not change it. |
| Cache |
File data kept in RAM to speed up disk access. The OS frees it automatically when a program needs memory. |
| Used incl. cache |
What most tools show as "used". Clearing the cache lowers this number. |
Auto clear runs when RAM including cache is at or above the threshold (default 95%) on two
samples in a row. It runs at most once every 15 minutes, and only when at least 1 GB would be
freed.
If programs use more than 90% of RAM (cache excluded), clearing the cache cannot help. The
extension then warns you and names the biggest processes.
One-time setup
Run RAM: Set Up Cache Clearing, or use the button on the dashboard.
- Linux: a command is typed into a terminal for you to review and run with your sudo
password. It installs a fixed, root-owned helper (
/usr/local/sbin/ram-monitor-drop-caches)
that only empties the page cache. It also adds one sudoers rule that allows exactly that helper,
with no argument or with 1, 2 or 3, to run without a password. If you set up 0.3.0 or
earlier, level 3 keeps working; levels 1 and 2 need the setup to be run once more.
Undo: sudo rm /etc/sudoers.d/ram-monitor /usr/local/sbin/ram-monitor-drop-caches
- macOS: same idea. The sudoers rule allows only the built-in
/usr/sbin/purge, with no
arguments. Undo: sudo rm /etc/sudoers.d/ram-monitor
- Windows: Windows asks once for administrator permission. The setup copies
clear-standby.ps1 to %ProgramData%\RAM, which only administrators can change, and registers
the scheduled task \RAM\Clear Standby Cache with highest privileges. Clearing then starts that
task with no prompt.
Undo: schtasks /Delete /TN "\RAM\Clear Standby Cache" /F and delete %ProgramData%\RAM.
Settings
| Setting |
Default |
|
ram.autoClear.enabled |
true |
Clear the cache automatically. |
ram.autoClear.thresholdPercent |
95 |
Threshold for RAM including cache. |
ram.autoClear.dropLevel |
1 |
Linux: 1 page cache only (gentlest, best for production servers), 2 dentries and inodes only, 3 both. |
ram.autoClear.minCacheGB |
1 |
Skip the clear if less cache than this would be freed. |
ram.autoClear.cooldownMinutes |
15 |
Minimum time between automatic clears. |
ram.pressureWarning.thresholdPercent |
90 |
Warn when programs (cache excluded) use this much. |
ram.sampleIntervalSeconds |
2 |
How often RAM is sampled. |
ram.historyMinutes |
30 |
How much history the graph shows. |
Notes
Memory per process:
- Linux: PSS for your 15 biggest processes and RSS for the rest.
- macOS: RSS.
- Windows: working set.
Shared memory is counted in every process that uses it, so totals are approximate.
Auto clear only runs while a VS Code window is connected to the machine.
iPhone and iPad cannot run VS Code extensions, so the extension cannot run there.
Development
npm test # node --test, no dependencies
npm run package # builds ram-cache-<version>.vsix
npm run publish # manual publish (needs a token); normally use the GitHub workflow below
Releasing
Releases use Trusted Publishing, so no token is needed:
- Raise
version in package.json and add a line to CHANGELOG.md.
- Push to this repository.
- On GitHub, run Actions → Publish RAM Cache → Run workflow, or push a tag such as
ram-cache-v0.7.1.
The workflow is .github/workflows/publish-ram-cache.yml. It runs the tests and then
vsce publish --oidc.
License
MIT, see LICENSE.