feat: automatische Heap-Überwachung integriert mit Reload bei Überschreitung
- 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
This commit is contained in:
@@ -79,6 +79,7 @@ import useDynamicDeviceLayers from "@/hooks/useDynamicDeviceLayers.js";
|
||||
import useDataUpdater from "@/hooks/useDataUpdater";
|
||||
import { cleanupPolylinesForMemory } from "@/utils/polylines/cleanupPolylinesForMemory";
|
||||
import { cleanupMarkers } from "@/utils/common/cleanupMarkers";
|
||||
import { monitorHeapAndReload } from "@/utils/common/monitorMemory";
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
//-------------------------------
|
||||
@@ -304,7 +305,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
// vorherige Marker & Polylinien vollständig bereinigen
|
||||
|
||||
markers.forEach(marker => {
|
||||
console.log("Marker-Typ:", marker.options);
|
||||
marker.remove();
|
||||
});
|
||||
cleanupPolylinesForMemory(polylines, map);
|
||||
@@ -780,6 +780,13 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
cleanupMarkers(markers, oms);
|
||||
};
|
||||
}, []);
|
||||
//--------------------------------------------
|
||||
// Überwacht den Speicherverbrauch und lädt die Seite neu, wenn er zu hoch ist, 8GB ist das Limit dann lädt die Seite neu
|
||||
useEffect(() => {
|
||||
const interval = monitorHeapAndReload(8, 10000);
|
||||
|
||||
return () => clearInterval(interval); // wichtig: aufräumen!
|
||||
}, []);
|
||||
//---------------------------------------------
|
||||
//--------------------------------------------
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user