deno: Memory leak in Deno (on Deno versions >= 1.31.0)
The below very simple program will ostensibly (at a rate of ~1MB/second) leak memory in Deno (only on Deno versions >= 1.31.0). To reproduce, please add a hello.txt file with a random content such as Hello! at the root and run the below program:
const file = new URL('./hello.txt', import.meta.url).pathname;
while (true) {
Deno.readFileSync(file);
}
The memory leak only happens on Deno versions >= 1.31.0. It does not happen on Deno versions <= 1.30.3. The memory leak is more significant with shorter files.
Here is a slightly longer version of the program that will output the memory usage every second :
console.log('Deno version', Deno.version.deno);
const file = new URL('./hello.txt', import.meta.url).pathname;
let timestamp = new Date();
while (true) {
if (Date.now() >= timestamp.valueOf()) {
const bytes = Deno.memoryUsage().rss;
console.log(timestamp.toISOString(), Math.floor(bytes / (1024 * 1024) * 10) / 10);
timestamp = new Date(timestamp.valueOf() + 1000);
}
Deno.readFileSync(file);
}
I have also created a repository that showcases the issue: https://github.com/quentinadam/deno-memory-leak.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 17 (9 by maintainers)
Commits related to this issue
- chore: upgrade rusty_v8 to 0.70.0 (#18844) Closes https://github.com/denoland/deno/issues/18369 — committed to denoland/deno by bartlomieju a year ago
- chore: upgrade rusty_v8 to 0.70.0 (#18844) Closes https://github.com/denoland/deno/issues/18369 — committed to lucacasonato/deno by bartlomieju a year ago
Bisected, and unfortunately it’s this:
No, it’s not. I will be released later this week 👍
We’ll look into the V8 upgrade problem this week.
Hey @lucacasonato unfortunately I cannot share the code. I have restarted a process with 1.32.1 and will try to capture the crashdump. It can take several hours so I’ll report back when I have something.