hls.js icon indicating copy to clipboard operation
hls.js copied to clipboard

Memory leak with re-render React component ?

Open AlexeyMikheev opened this issue 4 years ago • 0 comments

What do you want to do with Hls.js?

Hi. I am create application with React+Ts+Next.js. "hls.js": "1.1.3" After initializtion and umnouting functional component with instance Hls i see memory leak Hls. https://skr.sh/sCR973BTOgq.

  const hlsRef = useRef(null);

       useEffect(() => {
        hlsRef.current = new Hls();
        hlsRef.current.attachMedia(videoRef.current);
        hlsRef.current.on(Hls.Events.MEDIA_ATTACHED, () => {
            hlsRef.current.loadSource(src);
        });

        return () => {
            hlsRef.current?.destroy();
            hlsRef.current = null;
        };

    }, [videoRef.current]);

Bot if create instance as

hlsRef.current = new Hls({enable Worker: false});

memory leak is disappeared Memory Dump https://disk.yandex.ru/d/96H7ku7-NVfKjQ

What have you tried so far?

No response

AlexeyMikheev avatar Feb 10 '22 13:02 AlexeyMikheev