()
| 81 | } |
| 82 | |
| 83 | function getCgroupLimitMb(): number | null { |
| 84 | if (_cachedCgroupLimitMb !== undefined) return _cachedCgroupLimitMb; |
| 85 | |
| 86 | if (process.platform !== "linux") { |
| 87 | _cachedCgroupLimitMb = null; |
| 88 | return null; |
| 89 | } |
| 90 | |
| 91 | const v2Content = readCgroupFile(CGROUP_V2_MEMORY_MAX_PATH); |
| 92 | const v1Content = v2Content === null ? readCgroupFile(CGROUP_V1_MEMORY_LIMIT_PATH) : null; |
| 93 | |
| 94 | _cachedCgroupLimitMb = parseCgroupLimitMb(v2Content, v1Content); |
| 95 | if (_cachedCgroupLimitMb !== null) { |
| 96 | console.info( |
| 97 | `[SystemMemory] cgroup memory limit detected: ${_cachedCgroupLimitMb} MiB — ` + |
| 98 | `it governs memory-adaptive render behaviour instead of host RAM.`, |
| 99 | ); |
| 100 | } |
| 101 | return _cachedCgroupLimitMb; |
| 102 | } |
| 103 | |
| 104 | function readCgroupFile(path: string): string | null { |
| 105 | try { |
no test coverage detected