()
| 113 | * construction — every number shrinks as the process itself grows. |
| 114 | */ |
| 115 | export function memoryBudgetBytes(): number { |
| 116 | const free = os.freemem(); |
| 117 | const cgroup = cgroupMemoryAvailable(); |
| 118 | if (cgroup !== null) return Math.min(free, cgroup); |
| 119 | // darwinAvailable ⊇ free by construction (the sum includes free pages); |
| 120 | // max() guards a hypothetical undercounting parse. |
| 121 | const darwin = darwinMemoryAvailable(); |
| 122 | return darwin === null ? free : Math.max(free, darwin); |
| 123 | } |
no test coverage detected