Repository navigation
Conversation
A list of views cut back to fewer reused its array and left the views it dropped in the slots past its new end, so each stayed in memory, and through it the whole subtree it was in, until the list grew back that long: a view's children synced to fewer (syncChildren), a Dynamic or Show built again with fewer views (clear), an Each with fewer rows (setChildren), a text's attachments set again or dropped by SpansFunc (an element's children and spans, and the spans SpansFunc builds again), and the views told their layout in the last commit (laidOut). A chat list that mounts a few hundred rows while scrolled back and drops all but the last few dozen at its end kept every dropped row, close to 100 MB in a headless run. Each list now clears the slots it no longer uses, as accessories, canvases and labels already do. Fixes nsgo-dev#1021
updateLists filtered t.lists in place and left the lists it dropped in the slots past its new end, so a removed List stayed in memory, and through it the whole subtree it was in, while another list stayed. It now clears what is past the lists still live, as the other lists of views do. Fixes nsgo-dev#1021
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1021.
A list of views cut back to fewer reused its array and left the views it dropped in the slots past its new end, so each stayed in memory, and through it the whole subtree it was in, until the list grew back that long. Each list now clears the slots it no longer uses, as accessories, canvases and labels already do.
core/commit.go:syncChildrenclears the old children past the new end;commitRoundclearslaidOutbefore reusing it.core/tree.go:Tree.clearandsetChildrenclear what is past the region's new end;mountText'sSpansFunceffect clears the spans before building them again.core/ops.go:setTextclears the element's old children and spans.core/list.go(second commit):updateListsclears the tree's list of lists past the lists still live, which kept a removedListwhile another list stayed; it showed once an app moved its chat transcripts toList.core/core_test.go:TestViewsDroppedFromListsAreFreeddrops views from each kind of list (anEach's rows, aDynamic's views, an element text's and aSpansFunctext's attachments, views with anOnLayout, aList), then checks that they are collected. It fails on main in all six cases. Reverting any one of the eight changes alone fails at least one case.CHANGELOG.md: anUnreleasedline.This touches
core/tree.gonext to #1008's change indiscard, andcore/list.go'supdateLists, apart from #1027's change inupdateList; each pair merges cleanly apart from theCHANGELOG.mdline each adds at the end ofUnreleased.Targets
core,base,ui,tsx, thensgotool)Screenshots
None.
Verification
go tool nsgo test -run '^TestViewsDroppedFromListsAreFreed$' ./corefails on main atc70af8a7in all six cases (row2 stays in memory,view2 stays in memory,box0 stays in memorytwice,heard0 stays in memory,list stays in memory) and passes with both commits, three runs in a row.go tool nsgo checkon Linux x86_64 (the host): passes, before and after the second commit.go tool nsgo teston Linux x86_64 under Xvfb (GDK_BACKEND=x11,GSK_RENDERER=cairo), with the first commit: 3,070 passed, 8 failed, 59 skipped. The same 8 fail on main in the same environment (3,069 passed):TestAccessibilitySelectedAndExpandedReachATSPI(no AT-SPI registry),TestVideoShowsWhatIsBehindItsTransparentPixels(no GStreamer plug-in for the alpha WebM),TestInstanceDefaultPathStaysCompatible(the socket path passes the address limit under this run's longTMPDIR),TestEditorsTakeLinesLimitsAndSubmit(the submit count in the window title stays 0 under Xvfb), andTestDevPagesTakeTheTokenOutOfTheirAddress,TestWebHostChannel,TestWebStrictCSPandTestWebDevClientKeepsItsToken, which get no answer from the browser or DevTools here. With the second commit,go tool nsgo test ./core: 760 passed.c06fa6f4, whose only change to these files sincec70af8a7is fix(core): avoid full resolves for window environment reports #1000's incore/tree.go.nsgotestsoak of a desktop app on v0.2.0 with this change and two similar ones for out-of-flow boxes and edge bars, no removed node stayed reachable in any of ten scenarios over 300 cycles each; without them, reading a long chat transcript back and returning to its end kept about 9,600, and switching between transcripts laid out inLists kept the one left, about 770 nodes, through the tree's list of lists. On macOS (Apple M3, macOS 27.2.1) the app's count of live views stayed flat over a 10-minute series of heap profiles.-targettests, as nothing here is backend-specific; Windows, web and Apple's mobile targets.Checklist
fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.CHANGELOG.md'sUnreleasedhas a line for a capability users can see.