Animating a starfield scene with a large line count leads to application crashes

I have implemented a starfield effect using line objects. It works well with a small number of lines, but as the count size exceeds 1000, the application crashes shortly after. I suspect that the issue may be related to creating a new buffer geometry every time the position is updated, but I am not entirely certain. Can someone please review the code and provide insights into what might be causing the problem? Here is the code: Starfield - CodeSandbox

Found out that disposing bufferGeometry at the end of componnent cycle solves the problem

  useEffect(() => {
    return () => {
  }, [lineGeometry]);