Skip to content

Release the add-progress map once every state has arrived - #19

Merged
wf9a5m75 merged 1 commit into
developfrom
fix/add-progress-release-table
Nov 21, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
fix/add-progress-release-table

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

Why

A heap dump of the US antenna example (723,800 circles, Pixel 5a) showed a HashMap$Node[] of 2,097,152 slots with 0 slots filled (8.4 MB), held by AddProgressTracker.pending of the Circles collection.

pending was created as HashMap(newStates.size * 2) and emptied by remove as states arrived. HashMap never shrinks its table, so the empty table stayed for as long as the collection was on screen.

What

  • Size pending for n states at the 0.75 load factor (n / 0.75 + 1) instead of n * 2: a 1,048,576-slot table instead of 2,097,152 for 723,800 states, with no resize.
  • In finishIfDone, replace pending with a new empty HashMap once the last state has arrived.

Behaviour of onAddStart / onAddProgress / onAddEnd is unchanged.

Checked

  • :android-sdk-compose:testDebugUnitTest: 19 pass (AddProgressTrackerTest included)
  • :android-sdk-compose:apiCheck: pass
  • On device: the antenna page reaches "723800 / 723800 circles" and the "Adding to the map" line clears (onAddEnd fires). In the heap dump, HashMap$Node[] total drops from 9.3 MB to 0.9 MB and no table of 500k+ slots remains.

Related: MapConductor/android-sdk-core#54 (per-circle bookkeeping in core). The two are independent.

AddProgressTracker sized `pending` as HashMap(n * 2) and emptied it one
remove at a time. A HashMap never shrinks its table, so after 723,800
circles arrived it kept an empty 2,097,152-slot array (8.4 MB) for as
long as the collection was shown.

Size it for n at the 0.75 load factor (half the table while adding) and
replace it with an empty map when the last state arrives.
@wf9a5m75
wf9a5m75 merged commit 5165cf6 into develop Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant