Fix BSOD MEMORY_MANAGEMENT on low-RAM servers

- Dynamically compute JVM -Xmx based on system RAM instead of hardcoded 32g
- Reduce peak memory during session loading (inline JSON string, skip redundant clone)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-10 14:19:49 +01:00
co-authored by Claude Opus 4.6
parent 4b624693ec
commit 0a724aed71
3 changed files with 19 additions and 6 deletions
+5 -3
View File
@@ -721,12 +721,14 @@ export function normalizeLoadedSessionTransientFields(session: SessionState): Se
function readSessionFile(filePath: string): SessionState | null {
try {
const raw = fs.readFileSync(filePath, "utf8");
const parsed = JSON.parse(raw) as unknown;
// Inline readFileSync into JSON.parse so the raw string is not bound to a
// variable and can be GC'd immediately — avoids holding the full JSON text
// and the parsed object graph in memory simultaneously.
const parsed = JSON.parse(fs.readFileSync(filePath, "utf8")) as unknown;
const session = normalizeLoadedSessionTransientFields(normalizeLoadedSession(parsed));
const pkgCount = Object.keys(session.packages).length;
const itemCount = Object.keys(session.items).length;
logger.info(`Session geladen: ${filePath} (${pkgCount} Pakete, ${itemCount} Items, ${raw.length} Bytes)`);
logger.info(`Session geladen: ${filePath} (${pkgCount} Pakete, ${itemCount} Items)`);
return session;
} catch (error) {
logger.error(`Session-Datei nicht lesbar: ${filePath}: ${String(error)}`);