Skip to content

Commit

Permalink
Fix issue causing memory to explode on assets page (#19796)
Browse files Browse the repository at this point in the history
## Summary & Motivation

This array is used as a dependency to setup a bunch of listeners.
Because we're using `.map` we end up creating a new array on every
render which causes us to unregister and register a new set of listeners
endlessly. If your computer can keep up with the memory swapping then
everything seems fine but if it can't your tab quickly grows unbounded.

## How I Tested These Changes

Use the task manager and saw that the "Assets tab" is no longer using
50%+ CPU and that the memory usage isn't changing wildly.

<img width="792" alt="Screenshot 2024-02-14 at 1 49 45 PM"
src="https://github.com/dagster-io/dagster/assets/2286579/ef39d3a7-3768-408b-bccc-fa28d2b307ff">

(cherry picked from commit b2c9271)
  • Loading branch information
salazarm authored and jmsanders committed Feb 14, 2024
1 parent 04609da commit c3d2f61
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function useAssetsLiveData(
thread: LiveDataThreadID = 'default',
) {
return factory.useLiveData(
assetKeys.map((key) => tokenForAssetKey(key)),
React.useMemo(() => assetKeys.map((key) => tokenForAssetKey(key)), [assetKeys]),
thread,
);
}
Expand Down

0 comments on commit c3d2f61

Please sign in to comment.