- monitorHeapAndReload() in /utils/common/monitorMemory.js ausgelagert - automatische Heap-Prüfung im 10s-Intervall in MapComponent integriert - reload bei Überschreitung von 8 GB Heap zur Stabilisierung bei Langzeitbetrieb - useEffect-Cleanup ergänzt mit clearInterval für sauberes Entfernen bei Unmount - Ziel: frühzeitige Entlastung vor möglichem Memory Overflow
15 lines
430 B
JavaScript
15 lines
430 B
JavaScript
export const monitorHeapAndReload = (limitInGB = 8, intervalMs = 10000) => {
|
|
const limit = limitInGB * 1024 * 1024 * 1024;
|
|
|
|
return setInterval(() => {
|
|
const heap = performance.memory?.usedJSHeapSize || 0;
|
|
|
|
console.log("Heap:", (heap / 1024 / 1024).toFixed(2), "MB");
|
|
|
|
if (heap > limit) {
|
|
console.warn("🚨 Heap-Limit erreicht. Reload wird ausgeführt.");
|
|
location.reload();
|
|
}
|
|
}, intervalMs);
|
|
};
|