You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NavigateTo copies the whole history on every call, even with no undo provider; with an undo provider each retained action keeps two full snapshots (O(n) per navigation, ~125 MB at 50k entries) #72
Each of the up to maxHistorySize retained undo actions holds two full copies of the history.
The navigation list itself has no size cap.
This contradicts the docs:
docs/Architecture.md promises "O(1) navigation operations" and says "Configurable history limits prevent memory leaks".
docs/Design-Decisions.md ("History Limits … Prevents unbounded memory growth") doesn't hold, because the undo limit caps the number of snapshots, not their size.
Repro (net10.0, Release): time for 1000 further NavigateTo calls at a given history size
history= 1000 undo=False 8.0 ms heap=0 MB
history= 1000 undo=True 18.9 ms heap=3 MB
history= 10000 undo=False 31.9 ms heap=2 MB
history= 10000 undo=True 648.5 ms heap=24 MB
history= 50000 undo=False 167.7 ms heap=10 MB
history= 50000 undo=True 677.0 ms heap=125 MB
Suggested fix / acceptance criteria
Take no snapshot when undoRedoProvider is null.
Have NavigateToAction record only the delta instead of full before/after lists: the truncated forward items, the pushed item, and the before/after indices.
Optionally add a maxHistorySize to Navigation<T> (or its factory) that drops the oldest entries, so the history itself is bounded as the docs claim.
Tests:
Undo and redo after NavigateTo, including after forward history was truncated, restore identical stacks.
What's wrong
Navigation<T>.NavigateTosnapshots the whole item list on every call, even when no undo provider is configured and the snapshot is thrown away:Navigation/Navigation/Services/NavigationStack.cs
Lines 43 to 69 in d4bd627
With an undo provider it copies the list again, and
NavigateToActionthen copies both lists once more:Navigation/Navigation/Services/NavigateToAction.cs
Lines 20 to 33 in d4bd627
The result:
maxHistorySizeretained undo actions holds two full copies of the history.This contradicts the docs:
docs/Architecture.mdpromises "O(1) navigation operations" and says "Configurable history limits prevent memory leaks".docs/Design-Decisions.md("History Limits … Prevents unbounded memory growth") doesn't hold, because the undo limit caps the number of snapshots, not their size.Repro (net10.0, Release): time for 1000 further NavigateTo calls at a given history size
Suggested fix / acceptance criteria
undoRedoProvideris null.NavigateToActionrecord only the delta instead of full before/after lists: the truncated forward items, the pushed item, and the before/after indices.maxHistorySizetoNavigation<T>(or its factory) that drops the oldest entries, so the history itself is bounded as the docs claim.NavigateTo, including after forward history was truncated, restore identical stacks.NavigateTotime stays flat as the history grows.