mirror of
https://github.com/rubyjs/mini_racer
synced 2023-03-27 23:21:28 -04:00
DOC: add section about fork safety
This commit is contained in:
parent
d2f4eb5e1e
commit
f407f68b53
1 changed files with 21 additions and 0 deletions
21
README.md
21
README.md
|
@ -97,6 +97,27 @@ context.eval('bar()', filename: 'a/bar.js')
|
|||
|
||||
```
|
||||
|
||||
### Fork safety
|
||||
|
||||
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
|
||||
Sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
|
||||
|
||||
If you want to ensure your application does not leak memory after fork either:
|
||||
|
||||
1. Ensure no MiniRacer::Context objects are created in the master process
|
||||
|
||||
Or
|
||||
|
||||
2. Dispose manually of all MiniRacer::Context objects prior to forking
|
||||
|
||||
```ruby
|
||||
# before fork
|
||||
|
||||
require 'objspace'
|
||||
ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
|
||||
|
||||
# fork here
|
||||
```
|
||||
|
||||
### Threadsafe
|
||||
|
||||
|
|
Loading…
Reference in a new issue