node
node copied to clipboard
Buffer.from(await blob.arrayBuffer()) doesnt release the memory on Ubuntu
Version
20
Platform
Ubuntu
Subsystem
No response
What steps will reproduce the bug?
I have a code that records camera input from client into server as such :
async function saveIntoMp4(chunks) {
const options = {
type: "video/webm"
}
let blob = new Blob(chunks, options);
chunks.length = 0 // to stop any memory leaks
const buffer = Buffer.from(await blob.arrayBuffer());
try {
fs.writeFile(
`./videos/1.mp4`,
buffer,
() => console.log("video is saved!")
);
} catch (error) {
console.log(error)
}
}
However buffer take up the memory and doesn't let go of it on my Ubuntu 20.04.6 LTS. Everytime I run this function it keeps occupying more and more memory. I have no instance of console.log from the buffer or chunks or blob or any kind. I am not sure why the memory is not released and what I should do about it. I have used nodejs version 20 and 18.9 so far without any luck. Why blob.arrayBuffer doesn't release the used memory?
p.s. The issue doesn't happen with the same exact code and same flags and same node version on windows 11.
How often does it reproduce? Is there a required condition?
everytime
What is the expected behavior? Why is that the expected behavior?
I expect the memory to be freed after the instance of buffer is used.
What do you see instead?
Memory is being occupied over and over again everytime the function is called.
Additional information
No response