Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the AudioBuffer occupies too huge bytes? #89

Open
BHznJNs opened this issue Feb 18, 2023 · 0 comments
Open

Is the AudioBuffer occupies too huge bytes? #89

BHznJNs opened this issue Feb 18, 2023 · 0 comments

Comments

@BHznJNs
Copy link

BHznJNs commented Feb 18, 2023

Development environment:

  • Windows 11

  • Node.js v18.12.0

  • web-audio-api package version 0.2.2

Sample code

import waa from "web-audio-api"
import axios from "axios"

const url = "https://music.163.com/song/media/outer/url?id=1991012773.mp3" // audio url
const context = new waa.AudioContext()
axios.get(url, {
    responseType: "arraybuffer"
})
    .then((res) => res.data)
    .then((buffer) => {
        context.decodeAudioData(buffer,
            (audioBuffer) => {
                // do something ... 
            },
            (err) => {
                // do something ...
            },
        )
});

setTimeout(() => {}, 10000)

Then in the TaskManager, this Node.js process will occupy over 250 MB of memory.

I guess that there is a problem with the decodeAudioData function in the lib/utils.js, or is there any problem with my sample code?


By the package heapdump, I found that the AudioBuffer generated by the AudioContext.decodeAudioData function usually occupies over 50 MB of memory when the source audio file is less than 10 MB. Is that normal?

@BHznJNs BHznJNs changed the title There may be a memory leak problem with the AudioContext.decodeAudioData. Is the AudioBuffer occupies too huge bytes? Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant