Repository navigation
Release the add-progress map once every state has arrived - #19
Merged
Merged
Conversation
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.
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
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 byAddProgressTracker.pendingof theCirclescollection.pendingwas created asHashMap(newStates.size * 2)and emptied byremoveas states arrived.HashMapnever shrinks its table, so the empty table stayed for as long as the collection was on screen.What
pendingfornstates at the 0.75 load factor (n / 0.75 + 1) instead ofn * 2: a 1,048,576-slot table instead of 2,097,152 for 723,800 states, with no resize.finishIfDone, replacependingwith a new emptyHashMaponce the last state has arrived.Behaviour of
onAddStart/onAddProgress/onAddEndis unchanged.Checked
:android-sdk-compose:testDebugUnitTest: 19 pass (AddProgressTrackerTestincluded):android-sdk-compose:apiCheck: passonAddEndfires). 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.