Repository navigation
Cut per-shape bookkeeping in the collector and tile index - #54
Merged
Merged
Conversation
With the 723,800-circle antenna page on a Pixel 5a the Java heap sat a few percent under the 512 MB largeHeap limit. Three structures held one or more objects per circle only to find it again by id: - ShapeTileSet.indexById was a HashMap<String, Int>: a node and a boxed Int per shape, plus a 2M-slot table. It is now an ObjectIntMap, still replaced rather than changed once assigned. - OverlayCollector kept `listening`, a ConcurrentHashMap of every state it listens to, duplicating the flow map. It now finds them in the published map and the pending direct adds, and drops a write from a state that is no longer a member. - Each state got its own closure as listener. The collector is now the one listener for all its states (StateMutationListener).
This was referenced Nov 21, 2026
Merged
This was referenced Nov 21, 2026
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.
Why
The US antenna example (723,800 circles) on a Pixel 5a kept the Java heap a few percent under the 512 MB
largeHeaplimit. A heap dump showed about 500 B per circle, of which roughly 130 B was SDK bookkeeping that exists only to find a state by id.What
ShapeTileSet.indexById:HashMap<String, Int>→androidx.collection.ObjectIntMap<String>. NoHashMap$Nodeor boxedIntegerper shape. The map is still never changed after it is assigned (removebuilds a new one, as before), so the setsids()returns keep their snapshot semantics.OverlayCollector.listeningremoved: it duplicated theflowmap. The collector now looks states up in the map it last published pluspendingAdds(nowid -> state, holding only direct adds still inside the debounce).onMutateddrops a write from a state that is in neither the current map nor the pending adds, so a listener left behind by a missed membership change cannot deliver stale values.StateMutationSignal.listen(listener, state)with an internalStateMutationListener. The collector itself is the listener, instead of one closure per state. The lambdalistenoverload stays for tests.No public API change (
apiCheckpasses; the new interface is@InternalMapConductorApi).Measured (Pixel 5a, example-app debug, antenna page, MapLibre)
Heap dump, app heap, shallow:
java.util.HashMap$Nodejava.lang.IntegerConcurrentHashMap$NodeOverlayCollector$$ExternalSyntheticLambda0dumpsys meminfoJava Heap, same script for both builds (open the page, then toggle T-Mobile, Verizon and Alaska three times):Clamp target GC heaplog linesNo crash or OOM with either build during the run.
Checked
:android-sdk-core:testDebugUnitTest: 448 pass, includingOverlayCollectorMutationTest:android-sdk-core:apiCheck: pass