-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Memory leak in Deno (on Deno versions >= 1.31.0) #18369
Comments
I wasn't initially able to reproduce this, but then I used the file you had with just "Hello!" in it and I was able to. This is not reproducible on Windows it seems. |
Yes, the memory leak is more obvious with small files (I should have mentioned it). Although, I think the memory leak is also present with larger files too. I have the impression the memory leak is due to the loop, hence why the memory leak is more significant when the loop is faster (when reading smaller files). |
The memory leak also happens with console.log('Deno version', Deno.version.deno);
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);
}
const response = await fetch('http://localhost:8080');
await response.text();
} Here is a chart of the memory usage over the first 10 minutes when I run the program on MacOS ARM64 (I experience similar results on Linux x86-64): |
V8 is quite lazy when it comes to GC. Try There could very well be a memory leak, but this plot doesn't say much. |
@ry it still runs out of memory, but at a slower pace. I didn't test fetch though. For the fetch test, it should be run until it runs out of memory because something might be caching or utilizing system memory. |
@dsherret, when I run the program (the one reading the file) with However, having to resort to calling
|
I can confirm we are seeing this also on long running Deno processes in Deno v1.32.1 . After some time Deno exits with |
Do you get any sort of backtrace from the crash? |
Bisected, and unfortunately it's this:
|
We'll look into the V8 upgrade problem this week. |
We're floating a V8 patch to verify if this is a V8 regression. |
@naegelin Do you have a backtrace / crashdump for the error you are seeing? Is the code that is causing Deno to crash public? If not, are you able to share it with us privately (if so, you can email me at luca@deno.com). |
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. |
👀 |
Thank you for the fix! This is not yet included in v1.32.5, correct? |
No, it's not. I will be released later this week 👍 |
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 asHello!
at the root and run the below program: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 :
I have also created a repository that showcases the issue: https://github.com/quentinadam/deno-memory-leak.
The text was updated successfully, but these errors were encountered: