/
nayvok
/
livecoding
Обзор
Документация
Войти
/
nayvok
/
livecoding
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
runner/src/processMemory.ts
28 строк
797 B
nayvok
fix: harden sessions and WebRTC recovery
17 июн 2026, 22:02
17 июн 2026, 22:02
37b9a92
Код
Авторство
О чём код?
import { readFile } from 'node:fs/promises' export function parseResidentMemoryBytes(status: string): number | null { const match = status.match(/^VmRSS:\s+(\d+)\s+kB$/m) if (!match?.[1]) return null const kilobytes = Number(match[1]) if (!Number.isSafeInteger(kilobytes) || kilobytes < 0) return null return kilobytes * 1024 } export function isMemoryLimitExceeded( currentBytes: number | null, limitBytes: number, ): boolean { return currentBytes !== null && currentBytes > limitBytes } export async function readResidentMemoryBytes( pid: number, ): Promise<number | null> { if (process.platform !== 'linux') return null try { const status = await readFile(`/proc/${pid}/status`, 'utf8') return parseResidentMemoryBytes(status) } catch { return null } }