You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Assetgraph keeps a reference to all added assets. It keeps these references alive even when the last incoming relation to an asset is removed from the graph, essentially orphaning the asset. This is quite surprising from an end user perspective.
Suggestion
Stop tracking all assets in a Set in the AssetGraph instance. Instead, create a new Set of entry points, create a method called addEntryPoint that adds an Asset or assetConfiguration to the entry point set, and then change all findAssets-like functionality to use a graph traversal from the entry point set rather than filtering the now deprecated AssetGraph._assets Set.
Upsides
Assets that are disconnected are no longer in the graph and will eventually be garbage collected.
This is a more intuitive interface, since all normal programming works in a way where things are cleaned up once you no longer keep a reference to them in your current scope, unless you reconnect a reference to them somewhere
TODO
Figure out if this has major performance implications
The text was updated successfully, but these errors were encountered:
Thought a bit about this. One challenge is how to figure out whether a given url is already in the graph. We can't really keep a url => asset index like we do now, because then we would retain a reference to the asset that then wouldn't be GCed. I think traversing the entire graph would be the only option 😟
WeakSet and WeakMap allow for garbage collectable data structures.
They have some gotchas, e.g. they are not iterable themselves. However, there are ways to work around that. For example having a Set/Array that tracks all key names, then using .has() during iteration to check if it's still live, otherwise flush it from the known keys — a kind of manual GC check in a way :)
With the _urlIndex it looks like it doesn't require it to be iterable, the .set()/.get() / .has() & .delete() methods do everything it needs to in that file.
Currently Assetgraph keeps a reference to all added assets. It keeps these references alive even when the last incoming relation to an asset is removed from the graph, essentially orphaning the asset. This is quite surprising from an end user perspective.
Suggestion
Stop tracking all assets in a
Set
in the AssetGraph instance. Instead, create a newSet
of entry points, create a method calledaddEntryPoint
that adds an Asset or assetConfiguration to the entry point set, and then change allfindAssets
-like functionality to use a graph traversal from the entry point set rather than filtering the now deprecatedAssetGraph._assets
Set.Upsides
Assets that are disconnected are no longer in the graph and will eventually be garbage collected.
This is a more intuitive interface, since all normal programming works in a way where things are cleaned up once you no longer keep a reference to them in your current scope, unless you reconnect a reference to them somewhere
TODO
Figure out if this has major performance implications
The text was updated successfully, but these errors were encountered: