diff --git a/CHANGELOG b/CHANGELOG index 6f160c1..9fd59db 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,9 +2,10 @@ - 0.1.10 - - Fix leak: minor memory leak when disposing a context (20 bytes per context) + - Fix leak: memory leak when disposing a context (20 bytes per context) - Feature: added #heap_stats so you can get visibility from context to actual memory usage of isolate - Feature: added #dispose so you reclaim all v8 memory right away as opposed to waiting for GC + - Feature: you can now specify filename in an eval eg: eval('a = 1', filename: 'my_awesome.js') 09-03-2017 diff --git a/README.md b/README.md index 523efe1..6637794 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,19 @@ context.eval 'while(true){}' # => exception is raised ``` +### Rich debugging with "filename" support + +```ruby + +context = MiniRacer::Context.new +context.eval('var foo = function() {bar();}', filename: 'a/foo.js') +context.eval('bar()', filename: 'a/bar.js') + +# MiniRacer::RuntimeError is raised containing the filenames you specified for evals in backtrace + +``` + + ### Threadsafe Context usage is threadsafe @@ -226,6 +239,12 @@ A list of all V8 runtime flags can be found using `node --v8-options`, or else b Note that runtime flags must be set before any other operation (e.g. creating a context, a snapshot or an isolate), otherwise an exception will be thrown. +Flags: + +- :expose_gc : Will expose `gc()` which you can run in JavaScript to issue a gc +- :max_old_space_size : defaults to 1400 (megs) on 64 bit, you can restric memory usage by limiting this. +- **NOTE TO READER** our documentation could be awesome we could be properly documenting all the flags, they are hugely useful, if you feel like documenting a few more, PLEASE DO, PRs are welcome. + ## Controlling memory When hosting v8 you may want to keep track of memory usage, use #heap_stats to get memory usage: diff --git a/ext/mini_racer_extension/mini_racer_extension.cc b/ext/mini_racer_extension/mini_racer_extension.cc index eda8474..63c75d4 100644 --- a/ext/mini_racer_extension/mini_racer_extension.cc +++ b/ext/mini_racer_extension/mini_racer_extension.cc @@ -64,6 +64,7 @@ typedef struct { typedef struct { ContextInfo* context_info; Local* eval; + Local* filename; useconds_t timeout; EvalResult* result; } EvalParams; @@ -131,13 +132,25 @@ nogvl_context_eval(void* arg) { TryCatch trycatch(isolate); Local context = eval_params->context_info->context->Get(isolate); Context::Scope context_scope(context); + v8::ScriptOrigin *origin = NULL; // in gvl flag isolate->SetData(0, (void*)false); // terminate ASAP isolate->SetData(1, (void*)false); - MaybeLocal