Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can now enforce crude resource usage limits for scripts executing in the JS VM. Its not overly granular and has some caveats, but it appears to work. To limit the time a script can run: >>> rt = spidermonkey.Runtime() >>> cx = rt.new_context() >>> cx.max_time(5) # Specified in seconds, returns the previous value. 0 >>> cx.execute("while(true) {}") ... RuntimeError To limit the amount of memory is similar: >>> rt = spidermonkey.Runtime() >>> cx = rt.new_context() >>> cx.max_memory(10000) # Specified in bytes, returns the previous value. 0 >>> cx.execute("var f = []; var b = 100000; while(b-- > 0) f.push(b*0.9)") ... RuntimeError At the moment this looks like its limiting resources per context when in reality its per runtime. So if you limit to usage on a context, and some other script in the context is running above that limit, the limited context will fail. You can also get the current values without setting: >>> cx.max_time(10) ... >>> cx.max_time() 10 >>> cx.max_memory(10000) ... >>> cx.max_memory() 10000 Some minor tweaks to make the memory limit specified on the Runtime and to improve the reported errors to follow shortly. [#12]
- Loading branch information
Paul Davis
committed
May 11, 2009
1 parent
4d97105
commit e203f17
Showing
7 changed files
with
214 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters