Skip to content

Finalizer not running #6

@sfcgeorge

Description

@sfcgeorge

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:

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:

  1. Finalizer isn't running, not sure why.
  2. node_piped_runner.js needs a tiny tweak to return valid JSON.
  3. don't know... GC or something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions