Memory meter counts page cache as used memory under a cgroup limit

Open Beginner friendly
#17,414 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@jmcphers is already working on this.

Since Nov 24, 2026.

  • #17696 by @jmcphers — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
linux, typescript
Domain
performance

Research direction

Start in src/vs/platform/positronMemoryUsage/node/positronMemoryUsageUtils.ts at getSystemMemory() and read the macOS branch, which already discounts inactive and purgeable pages, as the pattern to mirror. Parse inactive_file / total_inactive_file from memory.stat (falling back to the current calculation when it is missing), then check how positronMemoryUsageService.ts turns the free value into the meter and the low-memory warning. Done looks like the example container reporting roughly 980 MB of 2.5 GB used and no warning.

Written by the indexing model from the issue text.

Description

area: workbench bug memory-use support

Summary

On Linux with a cgroup memory limit (for example, a Docker container or a Kubernetes pod), the memory meter in the Variables pane counts reclaimable page cache as used memory. As a result, the meter shows much more memory in use than the real working set. The low-memory warning can show when there is no memory pressure. The extra memory goes into the "Other" bucket, so it looks like an unknown process uses most of the container's memory.

We got this report from @mine-cetinkaya-rundel, who teaches with Positron Server in hosted containers. Students who see a large "Other" value look for a runaway process that doesn't actually exist.

Example

Positron Server 2026.08.1 in a Docker container with a 2.5 GB limit (cgroup v2). Fresh R session, no objects loaded.

The meter showed:

Category Reported
Positron total 982.75 MB (38%)
Other 1.42 GB (57%)
Free 124.91 MB (5%)

The low-memory warning was visible.

The cgroup contained:

memory.max      2684354560
memory.current  2613657600

anon            694161408
file            1788030976
inactive_file   1633513472
active_file     154517504
kernel          125603840

Most of memory.current is page cache, and most of that cache is inactive_file. The kernel reclaims inactive_file before it enforces the limit, so this memory cannot cause an OOM kill. A process listing showed only Positron processes. The working set (memory.current - inactive_file) is about 980 MB, which is 37% of the limit.

Cause

getSystemMemory() in src/vs/platform/positronMemoryUsage/node/positronMemoryUsageUtils.ts calculates free memory as the limit minus memory.current (cgroup v2) or minus memory.usage_in_bytes (cgroup v1). Both values include page cache. Each file that the container reads or writes (the Positron install, extensions, R and Python libraries, temporary files) adds to this value.

positronMemoryUsageService.ts then puts all memory that is not Positron into "Other". The low-memory check uses the same free value.

The macOS path in the same file already counts inactive and purgeable pages as free memory. The Linux cgroup path does not do the same.

Proposed fix

Subtract inactive file cache from usage. This is the calculation that docker stats and the Kubernetes container_memory_working_set_bytes metric use.

  • cgroup v2: used = memory.current - inactive_file (from memory.stat)
  • cgroup v1: used = memory.usage_in_bytes - total_inactive_file (from memory/memory.stat)
  • free = limit - used

If memory.stat is not available, keep the current calculation.

With this change, the example session shows about 980 MB used of 2.5 GB, and the low-memory warning would not show. "Other" decreases to about zero. Process RSS includes some file-mapped pages, so "Other" stays an estimate.

Dominant language
TypeScript
Stars
4.4k
Forks
207
Avg merge
1d 16h
Merged PRs (30d)
308

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from posit-dev/positron

All issues in posit-dev/positron

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.