mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(engine): use totalmem() instead of freemem() for memory scaling
Addresses review feedback: freemem() is misleading on macOS where aggressive file caching reports low free memory even on high-spec machines. Switched to totalmem()-based thresholds consistent with calculateOptimalWorkers in parallelCoordinator.ts. Thresholds now based on total RAM: - <4GB total: GPU=512MB, V8=256MB, cache=32/128MB - <8GB total: GPU=1024MB, V8=512MB, cache=64/256MB - >=8GB total: unchanged (4096MB GPU, no V8 cap, 256/1500MB cache)
This commit is contained in:
@@ -208,26 +208,25 @@ export const DEFAULT_CONFIG: EngineConfig = {
|
||||
debug: false,
|
||||
};
|
||||
|
||||
function getSystemFreeMb(): number {
|
||||
function getSystemTotalMb(): number {
|
||||
try {
|
||||
const { freemem } = require("os") as typeof import("os");
|
||||
return Math.floor(freemem() / (1024 * 1024));
|
||||
return Math.floor(require("os").totalmem() / (1024 * 1024));
|
||||
} catch {
|
||||
return 8192;
|
||||
return 16384;
|
||||
}
|
||||
}
|
||||
|
||||
function memoryAdaptiveCacheLimit(): number {
|
||||
const free = getSystemFreeMb();
|
||||
if (free < 2048) return 32;
|
||||
if (free < 4096) return 64;
|
||||
const total = getSystemTotalMb();
|
||||
if (total < 4096) return 32;
|
||||
if (total < 8192) return 64;
|
||||
return DEFAULT_CONFIG.frameDataUriCacheLimit;
|
||||
}
|
||||
|
||||
function memoryAdaptiveCacheBytesMb(): number {
|
||||
const free = getSystemFreeMb();
|
||||
if (free < 2048) return 128;
|
||||
if (free < 4096) return 256;
|
||||
const total = getSystemTotalMb();
|
||||
if (total < 4096) return 128;
|
||||
if (total < 8192) return 256;
|
||||
return DEFAULT_CONFIG.frameDataUriCacheBytesLimitMb;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user