Add operation-based auto garbage collection for images

Introduces an operation counter and threshold in ImageReferenceManager to trigger automatic garbage collection after a set number of canvas operations. Canvas now increments the operation count on save, undo, and redo, and exposes methods to set the operation threshold and retrieve stats including operation count. CanvasView displays the operation count and threshold after manual garbage collection.
This commit is contained in:
Dariusz L
2025-06-26 19:18:05 +02:00
parent 48005247fb
commit 3ca0a32a14
3 changed files with 67 additions and 3 deletions

View File

@@ -681,7 +681,7 @@ async function createCanvasWidget(node, widget, app) {
const newStats = canvas.getGarbageCollectionStats();
log.info("GC Stats after cleanup:", newStats);
alert(`Garbage collection completed!\nTracked images: ${newStats.trackedImages}\nTotal references: ${newStats.totalReferences}`);
alert(`Garbage collection completed!\nTracked images: ${newStats.trackedImages}\nTotal references: ${newStats.totalReferences}\nOperations: ${newStats.operationCount}/${newStats.operationThreshold}`);
} catch (e) {
log.error("Failed to run garbage collection:", e);
alert("Error running garbage collection. Check the console for details.");