microsoft / microsoft/vscode

`code --status` multiplies process memory twice on macOS and Linux

Open
#331,296 0 comments 0 reactions 1 assignee Claimed by @deepak1556 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Does this issue occur when all extensions are disabled?: Yes (the calculation is independent of extensions)

- VS Code Version: 1.133.0 (a5b500951314efd502d07465bd138dfbd714a960)
- OS Version: macOS 26.5.1, arm64

## Steps to reproduce

1. Run `code --status`.
2. Inspect the `Mem MB` values in the process table.

## Actual result

The command reports impossible process-memory values. In one current sample:

- `code --status`: 25,332,747,904 MB for PID 68258
- `ps` RSS for the same PID: 96,624 KiB (about 94 MiB)

## Root cause

`listProcesses` already normalizes `ProcessItem.mem` to bytes on non-Windows platforms:

```ts
mem: isWindows ? mem : (totalMemory * (mem / 100))
```

However, `DiagnosticsService.formatProcessItem`, which formats `code --status`, still treats `item.mem` as a percentage on macOS and Linux and multiplies it by total system memory again:

```ts
const memory = process.platform === 'win32' ? item.mem : (osLib.totalmem() * (item.mem / 100));
```

The formatter should consistently convert the byte value with `item.mem / ByteSize.MB`.

## Scope

This is adjacent to, but separate from, #194322 and #331139. Those address which memory metric Process Explorer obtains on macOS. This issue concerns the deterministic double conversion in the `code --status` text formatter. PR #331139 continues to provide `ProcessItem.mem` in bytes, so it does not correct this output path.

The same formatter branch is used on Linux, although the reproduction above is from macOS.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.