Greetings!

I'm building a system that embeds V8 as its configuration/scripting
engine, and I'll be allowing clients to edit their own scripts. To
allow this safely, I need to put constraints on what the scripts can
do.

My goal is to limit the amount of memory V8 will use, to prevent stuff like:
a="a"; while (1) a=a+a;
from bringing the system to its knees. With
v8::SetResourceConstraints() it ought to be possible, but I'm not sure
how this is meant to work.

ResourceConstraints r; r.set_max_young_space_size(1<<24);
r.set_max_old_space_size(1<<24); r.set_max_executable_size(1<<20);
SetResourceConstraints(&r);

Unfortunately there's not a lot of documentation explaining what these
limits mean. I presume 'young' and 'old' have to do with the garbage
collector, but is the sum of those two values the limit of heap space?
With the above constraints applied, my script was able to reach 500MB
using the above thrash script, before bombing with an out-of-memory
error.

Alternatively, is there some other way to control memory allocation?

Thanks!

Chris Angelico
aka Rosuav

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to