clean up subscriptions & component references #5713
Merged
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.
Profiling revealed various memory issues involving the block overview component, which could prevent old copies of data used for the block visualization from being properly garbage collected after use:
this
).ngOnDestroy
handler, those subscription callbacks are never cleaned up and the references to the component instance are retained indefinitely, preventing the component object from being properly garbage collected after the end of its natural lifecycle.shareReplay
:shareReplay
rxjs operator prevents the event source from being automatically unsubscribed, even if all of the downstream subscriptions are correctly cleaned up.refCount
parameter should be used to ensure the source is unsubscribed at the end of its lifetime, likeshareReplay({ bufferSize: N, refCount: true })
.BlockOverviewGraphComponent
being correctly garbage collected to clean up the memory intensive block visualization objects instead of proactively clearing this data at the end of its Angular lifecycle.This PR attempts to resolve these issues by:
shareReplay
to userefCount
.destroy()
on theBlockScene
andFastVertexArray
instances in theBlockOverviewGraphComponent.ngOnDestroy
handler to clean up that data.Testing
/mempool-block/...
,/block/...
, dashboard, acceleration dashboard) for a while.BlockOverviewGraphComponent
and/orBlockScene
objects have been retained.