I added a snippet of code like this to manually destroy old contexts and that caused a JSON parse error:
js = ExecJS.compile("function foo() {}")
# ... do stuff with the context ...
runtime = js.instance_variable_get :@runtime
uuid = js.instance_variable_get :@uuid
runtime.vm.delete_context(uuid) # what the finalizer is supposed to do
But that was easy to fix by editing node_piped_runner.js to return [1] instead of 1 as bare values aren't valid top level JSON.
Unfortunately deleting the context still doesn't seem to be freeing up memory and I don't know why. I tried doing global.gc() but that needs the --expose-gc flag but passing flags doesn't seem to work (or I did it wrong). I'm not convince running an extra GC is the answer anyway, but I don't know where to look next to fix the leak.
TLDR:
Finalizer isn't running, not sure why.
node_piped_runner.js needs a tiny tweak to return valid JSON.
I believe the finalizer that deletes old contexts is not running because as I added more and more specs (using by capybara-jsdom driver that uses execjs-fastnode) eventually I got out-of-memory errors.
I added a snippet of code like this to manually destroy old contexts and that caused a JSON parse error:
But that was easy to fix by editing node_piped_runner.js to return
[1]
instead of1
as bare values aren't valid top level JSON.Unfortunately deleting the context still doesn't seem to be freeing up memory and I don't know why. I tried doing
global.gc()
but that needs the--expose-gc
flag but passing flags doesn't seem to work (or I did it wrong). I'm not convince running an extra GC is the answer anyway, but I don't know where to look next to fix the leak.TLDR: