lib/capybara/jsdom/browser.rb
# Each `load` creates a new context that is then reused for every
# `command`. Thus with a lot of tests loading a lot of pages the
# Node server keeps a lot of contexts open and runs out of memory.
# We must destroy previous contexts before each load.
# This may mean we can't parallelize.
# ExecjsFastnode does have a finalizer for this purpose but it doesn't
# seem to work.
# https://github.com/jhawthorn/execjs-fastnode/blob/be8033387d61c58244d75cf4c1ee1b09b7151a70/lib/execjs/fastnode/external_piped_runtime.rb#L119
Each `load` creates a new context that is then reused for every
`command`. Thus with a lot of tests loading a lot of pages the
Node server keeps a lot of contexts open and runs out of memory.
We must destroy previous contexts before each load.
This may mean we can't parallelize.
ExecjsFastnode does have a finalizer for this purpose but it doesn't
seem to work.
Each ` load ` creates a new context that is then reused for every ` command ` . Thus with a lot of tests loading a lot of pages the Node server keeps a lot of contexts open and runs out of memory . We must destroy previous contexts before each load . This may mean we can ' t parallelize . ExecjsFastnode does have a finalizer for this purpose but it doesn ' t seem to work .
def destroy_previous_contexts
        return unless $js
        runtime = $js.instance_variable_get :@runtime
        uuid = $js.instance_variable_get :@uuid
        runtime.vm.delete_context(uuid)
      end
def destroy_previous_contexts return unless $js runtime = $js . instance_variable_get :@runtime uuid = $js . instance_variable_get :@uuid runtime . vm . delete_context ( uuid ) end
Each `load` creates a new context that is then reused for every
`command`.
Each ` load ` creates a new context that is then reused for every ` command ` .