Skip to content

Can virtua cause memory leak on frequent scroll #258

Answered by inokawa
morajabi asked this question in Q&A
Discussion options

You must be logged in to vote

I hope it is not caused by virtua. In theory it will not cause memory leak but there are several things that might help:

  • If props.children is ReactNode, it is flattened to array and keeped with useMemo.
  • Items' sizes and offsets are cached in number array. The length will match total length of items.
  • Item's actual DOM is keeped in WeakMap to associate DOM and item's index until unmount.
  • Items are observed with ResizeObserver on mount and unobserved on unmount.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by morajabi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants