MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / getCgroupLimitMb

Function getCgroupLimitMb

packages/engine/src/services/systemMemory.ts:83–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83function 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
104function readCgroupFile(path: string): string | null {
105 try {

Callers 1

getSystemTotalMbFunction · 0.85

Calls 3

readCgroupFileFunction · 0.85
parseCgroupLimitMbFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected