-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugSomething isn't working correctlySomething isn't working correctlydeno_coreChanges in "deno_core" crate are neededChanges in "deno_core" crate are needed
Description
Hello. So, I was testing Deno 1.9.2 with a workload that involves Temporal and a Postgres database. I noticed that after a few minutes, the 2GB VPS just ran out of memory after some batches of processing. I did the following:
- Tried to profile using
--inspect
, but I noticed that it never went above 20MB, so it was probably not a "normal" JavaScript leak. I think Deno lacks GC information in the DevTools profiler, so that wasn't helpful. - I proceeded to compile Deno in debug mode, upload to VPS, run with the workload using
LD_PRELOAD=/usr/lib/libtcmalloc.so
and aHEAPPROFILE
. - The results were in. And looks like it's Intl.DateTimeFormat that is at fault.
- Then I looked for similar issues. Found: Memory leak when using Intl.DateTimeFormat.format() and Intl.NumberFormat.format() nodejs/node#31914, seems related, and listed as fixed for v8, but let's try the repro. Created a file leak.ts, ran with deno and watched the resident memory climb up to 5.4G. Ran with node, it also looks "leaky", but it only goes up to 1.3G.
setInterval(() => {
var a;
for (let i = 0; i < 100; i++) {
a = new Intl.DateTimeFormat("en").format(Date.now());
}
}, 1);
- The same code with a similar object,
Intl.NumberFormat
, peaks at 100M for node, and 258M for deno. I assume that is normal.
setInterval(() => {
var a;
for (let i = 0; i < 100; i++) {
a = new Intl.NumberFormat("en").format(3);
}
}, 1);
- I couldn't change this memory ceiling by using
--v8-flags=--max-old-space-size
, so I guess it's completely external to that.
I think it's probably an issue in V8 itself that has not been correctly resolved, and deno and node both handle it differently. I will try to change Temporal to reuse the same Intl.DateTimeFormat
instance, for now, but it would be nice if this could be fixed.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctlydeno_coreChanges in "deno_core" crate are neededChanges in "deno_core" crate are needed