Repository navigation
Closed
Description
Problem Statement
With multiple tabs/panes open, memory usage and performance can degrade. We need to:
- Monitor and optimize memory consumption
- Implement lazy loading of node data
- Add cleanup when tabs close
- Profile and optimize render performance
Current State
What Exists:
- ✅ Multiple ReactiveNodeService instances
- ✅ SharedNodeStore with subscriptions
What's Missing:
- ❌ Memory profiling and monitoring
- ❌ Lazy loading for inactive tabs
- ❌ Cleanup logic for closed viewers
- ❌ Performance budgets and alerts
Proposed Solution
Performance optimization strategy:
- Profile memory usage with dev tools
- Implement lazy loading for inactive tabs
- Add proper cleanup on viewer destruction
- Set performance budgets (target <100MB for 5 tabs)
- Optimize re-render paths
Key Areas
Memory Management:
- Track memory usage per viewer
- Implement cleanup for closed tabs (unsubscribe, clear caches)
- Monitor for memory leaks
Lazy Loading:
- Don't load node data for inactive tabs until viewed
- Unload data for long-inactive tabs (configurable threshold)
Render Optimization:
- Profile render performance
- Minimize unnecessary re-renders
- Optimize update propagation
Main Components Affected
Modified Files:
/packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts- Add cleanup/packages/desktop-app/src/lib/services/shared-node-store.ts- Optimize subscriptions/packages/desktop-app/src/lib/components/base-node-viewer.svelte- Lazy loading
Performance Targets
- Tab switching: <50ms
- Opening new tab: <100ms
- Memory usage: <100MB for 5 tabs
- No memory leaks over 100 tab open/close cycles
Acceptance Criteria
- Memory profiling shows no leaks
- Tab switching meets performance targets
- Lazy loading reduces initial memory footprint
- Cleanup properly unsubscribes and clears caches
- Performance monitoring in place
Estimated Effort
4-6 hours
- Memory profiling: 1 hour
- Lazy loading implementation: 2 hours
- Cleanup logic: 1 hour
- Optimization and testing: 2 hours
Dependencies
- Requires: Implement Tab/Pane Management UI (Phases 4-8) #206 (EPIC), Implement nodespace:// Link Navigation with Dynamic Tab Creation #297, Tab UI Controls: Hover-to-Show Close Button #298, Split-Pane Layout System #300
- Should follow: Most other Phase 4 work
Priority
Medium - Important for production quality but can be addressed after core features work
Activity
malibio commentedon Aug 3, 2026
Dependency and status check — the premise still holds, with one claim unverified.
All stated dependencies are closed: #206 (Tab/Pane Management), #297 (link navigation), #298 (tab controls), #300 (split-pane layout).
Confirmed present, as the issue assumes:
lib/components/layout/tab-system.svelte,pane-manager.svelte,app-shell.svelte,lib/stores/layout.svelte.tslib/services/tab-persistence-service.ts,layout-persistence-service.tsSharedNodeStorewith subscriptions —lib/services/shared-node-store.svelte.tslib/design/components/node-component-loader.svelte.ts,schema-form-loader.svelte.tslib/services/node-expansion-coordinator.ts:77-85,254Unverified: the issue asserts there is no cleanup logic on tab close (unsubscribe, clear caches). I did not trace the tab-close path, so that claim should be confirmed before any work starts — it may be partly handled. The "lazy loading for inactive tabs" gap is distinct from the node-level lazy loading above and does appear to be real.
Note the file paths in the body are stale in one place:
/packages/desktop-app/src/lib/components/base-node-viewer.svelteis actually atlib/design/components/base-node-viewer.svelte. Thereactive-node-service.svelte.tsandshared-node-storepaths are correct.Suggest the first step is profiling to confirm there is a real leak before implementing lazy-unload machinery.
mstomar125 commentedon Aug 3, 2026
Parked for on-device (Mac) — this is frontend-visual, not backend-tractable headless
Every axis of this issue needs the running desktop app + a profiler, which a headless backend environment can't provide:
<100 MB for 5 tabsbudget requires the Tauri app's dev tools against real open tabs; there's nothing to measure headlessly.ReactiveNodeService/SharedNodeStorelifecycle (subscribe/unsubscribe, cache clearing on viewer destruction). Correctness here ("did closing a tab actually release its memory / unsubscribe?") is only verifiable by running the app and watching the profiler, not by unit tests.Labeled
frontend/performance, and it belongs to the desktop/frontend lane. Parking it here for the Mac.Suggested first cut when picked up on-device: instrument per-viewer memory (a dev-only overlay), then add deterministic cleanup on viewer destruction (unsubscribe from
SharedNodeStore+ clear the viewer's node cache) and confirm the release in the profiler before moving to lazy-load/unload thresholds. The backend already exposes what's needed (per-node fetch, subscriptions); the gap is entirely frontend lifecycle + measurement.mstomar125 commentedon Sep 11, 2026
Triage — closing as superseded by #2568
Re-verified this from scratch against the current codebase (11 months since filing) rather than trusting the prose, including a real headless measurement.
What actually exists today (vs. this issue's description):
ReactiveNodeService(packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts) is no longer a thing that holds its own node data per viewer. It's now a thin per-viewer UI-state adapter (expand/collapse, focus, depth) that delegates all node storage to a single globalSharedNodeStoresingleton (SharedNodeStore.getInstance()). Itsdestroy()method — the exact call everyBaseNodeViewermakes on unmount — is an explicit documented no-op: "Node data reactivity now comes directly from SharedNodeStore's SvelteMap — there is no subscription to tear down."SharedNodeStoreis confirmed present as this issue assumed, with subscriptions (subscribe()/subscribeAll()), but it's a single app-wide singleton, not one per tab.closeTab()(packages/desktop-app/src/lib/stores/navigation.svelte.ts:332) only cleans up scroll-position state and tab/pane bookkeeping — it never touchesSharedNodeStore.node-component-loader.svelte.ts,schema-form-loader.svelte.tslazy-load Svelte component bundles per node type). There is no lazy loading / unloading of node data by tab-active state — this part of the original proposal is still genuinely missing.bun run test:perf/architecture-benchmarks.test.ts, but its one memory test is an explicit formula-based estimate and only exercises a singleReactiveNodeService— no multi-tab coverage existed before this triage.Real measurement (not just code-reading): wrote and ran a headless probe that opened 10 simulated tabs × 300 distinct nodes (3,000 total) into the real
SharedNodeStoreviacreateReactiveNodeService()+initializeNodes(), then calleddestroy()on all 10 (the same call every real tab-close triggers). Result: the shared store held 3,000 nodes before and after "closing" every tab — nothing was released. Heap grew ~16.5MB for those 3,000 plain node objects in the headless harness (no forced GC, so directional only, not a production number). This confirms the underlying concern is real, just shaped differently than originally described: it's not "N per-viewer duplicated caches," it's "one shared cache that only ever grows, with no eviction of documents no longer open anywhere."Decision: closing this as stale/superseded — the architecture it describes (per-viewer duplicated node data, needing per-viewer cleanup) no longer exists, and its proposed solution doesn't match the current single-shared-store shape. Filed #2568 with the accurate current architecture, the real measurement above, and a tight, currently-relevant acceptance-criteria list (real memory test using
process.memoryUsage(), actual eviction tied to tab-close + an inactivity threshold, correctness for the existing multi-pane-same-node case, no eviction of nodes with pending writes). All of the original dependencies (#206, #297, #298, #300) remain closed, so #2568 is immediately pickable.