fix(metrics): use vm_stat for accurate macOS memory reporting#45
Draft
fix(metrics): use vm_stat for accurate macOS memory reporting#45
Conversation
On macOS, systeminformation calculates available = total - Pages_active, which incorrectly includes wired/compressed memory as available. Parse vm_stat directly to properly calculate available memory as (free + inactive + purgeable + speculative) * pageSize. Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
- Fix misleading JSDoc comment on getMacOsMemory fallback - Add maxBuffer option to execSync to prevent memory exhaustion - Add comment explaining default 16KB page size choice Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate reduced memory availability on macOS
fix(metrics): use vm_stat for accurate macOS memory reporting
Feb 28, 2026
Add mocks for node:child_process and node:os in metrics.test.ts so getMacOsMemory() returns controlled values on macOS instead of calling real vm_stat. The mock vm_stat output produces exactly 4096 MB active and 8192 MB available, matching the existing test expectations. Co-authored-by: Garbee <868301+Garbee@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
macOS memory appeared halved (~7GB on 14GB runners) because
systeminformationcalculatesavailable = total - Pages_active, misclassifying wired and compressed memory as available.macOS memory parser (
src/lib.ts)parseMacOsVmStat()— parsesvm_statoutput directly, computing available as(free + inactive + purgeable + speculative) × pageSize, matching Activity Monitor's definitionvm_statheadergetMacOsMemory()wrapper withexecSyncfallbackMetrics collection (
src/main/metrics.ts)darwin, callsgetMacOsMemory()instead ofsysteminformation.mem(). Other platforms unchanged.Test fix (
src/main/metrics.test.ts)node:child_process(execSync→ controlled vm_stat output) andnode:os(totalmem→ fixed value) sogetMacOsMemory()returns deterministic values on macOS CI runnersnode:osexports to preserveEOLetc. for@actions/core✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.