Skip to content

Memory leak #46

@hnuuhc

Description

@hnuuhc

Steps to reproduce

In the default example, a memory leak may occur after multiple loops, possibly due to the failure to release streams.

for (const VIDEO_ID of list) {
    if (igoreList.includes(VIDEO_ID)) continue

    console.log(`-> ${VIDEO_ID}`)
    try {
        const { streamResults: {
            videoStream
        }, player } = await createSabrStream(VIDEO_ID, OPTIONS)

        if ((player.video_details?.duration ?? 0) > 7200) {
            igoreList.push(VIDEO_ID)
            igoreFile.writeJson(igoreList)
            continue
        }

        console.info(`
    Title: ${player.video_details?.title ?? 'Unknown Video'}
    Duration: ${player.video_details?.duration}
    Views: ${player.video_details?.view_count}
    Author: ${player.video_details?.author}
    Video ID: ${player.video_details?.id}
  `)

        new File(folder, 'video', VIDEO_ID).mkdir()
        const videoFile = new File(folder, 'video', VIDEO_ID, `${VIDEO_ID}.video`)

        const write = createStreamSink(createWriteStream(videoFile.path()))

        await videoStream.pipeTo(write)

        videoFile.move(new File(folder, 'video', `${VIDEO_ID}.webm`))
        new File(folder, 'video', VIDEO_ID).delete()

        igoreList.push(VIDEO_ID)
        igoreFile.writeJson(igoreList)
    } catch (e) {
        console.error(e)
    }

}

Failure Logs

no errer

Expected behavior

Memory is normal

Current behavior

Memory leak

Version

Default

Anything else?

No response

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions