Open psbrandt opened 8 months ago
Hi! @sbrandt 😋
I've once investigated the same thing.
The thought is that the deno_core::JsRuntime
does not seem to cover the case spawning more than one isolate. If you look inside it, you'll see how it handles ExternalReferences
or OpCtx
, they just leak away, and they never get freed when the isolate is dropped.
Then, when you think about why it leaked, I can't shake the feeling that JsRuntime
was designed only for sole isolation. If JsRuntime
was designed without considering that the user can spawn many JsRuntime
, they might think that the ExternalReferences
or OpCtx
might be okay to leak away.
I've seen once somewhere that a recent memory leak was related to EPT or pointer compression^ticket. However, I can't find anywhere a statement such as that the array of the external_references
will be freed if the isolation drops. Looking at EPT, it sounds capable of garbage collecting, so I once thought something like the EPT could clean up the external_references
, but I don't know how it works with the external references.
That's all I knew about that problem! I hope this helps! 😁
Hi,
I have a long running service that creates (and destroys) many Deno runtimes over its lifespan. The service has slowly been leaking memory over time and I've been trying to investigate what the cause might be. What I've discovered is that an application that contains only the following code seems to leak memory:
I believe this to be case because I get the following when running DHAT:
The full DHAT viewer output can be seen in my test repository here [PDF]. The raw DHAT JSON output is also available there.
It looked like the WASM engine was responsible for some of the leaked memory, so I did a custom build of V8 without WASM as follows:
Running DHAT then gives the following output:
DHAT viewer output here [PDF].
I also tried both of the tests above with
jemallocator
, but that didn't make a huge difference. See the results of those tests in my test repo.Is my assumption correct that there should be no memory leaks (i.e.
t-end
should equal0
in the DHAT output above) with the simple code I provided?Am I doing something else wrong? Any tips on how I might be able to investigate further?