php-spidermonkey
php-spidermonkey copied to clipboard
Configure Script Memory Usage (and potentially execution time)
It'd be great to be able to configure the amount of memory that can be used by a script.
I believe this is currently set using PHP_JSRUNTIME_GC_MEMORY_THRESHOLD. It'd be great to expose this through the context interface in PHP.
Also, would it be possible to implement a max execution time on a script? I looked at the Python SpiderMonkey source and it looks possible using callbacks. It's also exposed in a nice way through their API.
Thanks,
Rob
+1
+1
I will add a way to change PHP_JSRUNTIME_GC_MEMORY_THRESHOLD through an ini value, but for the max execution time it cannot be done unless we revert the extension to an older spidemonkey version (pre-JIT <1.8.1). What the python extension does is use that older version and implements the branch callback that is called everytime the code branch. It was removed by Mozilla in favor of another API, but using this API means creating threads to monitor the execution, which is clearly not recommended in a PHP extension.