Subj : Implementing Resource Control in Spider Monkey To : netscape.public.mozilla.jseng From : sajidraza@hotmail.com (S. Raza) Date : Mon Mar 08 2004 12:35 pm I'm interested in implementing some form of resource control for scripts that execute in my application. Specifically, CPU and memory consumption need to be managed, on a per script basis. Ideally :) I'd like to do this without modifying the internals of the scripting engine. I can see that Spider Monkey supports limiting the stack-size for a context out of the box (great). However, for heap-based objects I don't see how this could be accomplished on a per context basis without some changes. I guess allocating a runtime per-script with a max runtime size begins to address the memory issue, however, allocating a new JSRuntime object for each script request might be too much. I'm thinking about intercepting calls to JS_NewObject. Would that be reasonable? Secondly for CPU usage, the js_Interpret function seems to be a nice place to inject any CPU usage checks. Basically for let the interpreter execute for N ops, and then check the elapsed 'real' CPU usage for the process each time. The other possibility as in JSEAL is to re-write byte-code to enable call-backs into CPU usage checking code after executing some block of code. TIA, Raza .