automatically shrink aggregation lists (#8657)
### Description
When unloading tasks, edges from the aggregation structure are removed,
but their memory is not reclaimed as Vecs don't shrink automatically.
This adds a `shrink_amortized` method which shrinks the Vec/HashMap when
capacity is 2 times larger than length.
This also calls `shrink_to_fit` when running GC on a task.
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->