Subj : Re: Exceptions and Object Lifetimes To : netscape.public.mozilla.jseng From : "Pete Diemert" Date : Wed Dec 17 2003 11:39 am Actually found the answer to #1 below (my bug, was setting exception info properly but was not returning JS_FALSE from our native ctor, therefore no throw). However, any thoughts on #2 are still much appreciated. "Pete Diemert" wrote in message news:bro6ne$es52@ripley.netscape.com... > > Hello, this is my first post to this group, if I am posting in the wrong > place please let me know. We have been working to embed the Spidermonkey > 1.5 engine with great progress however there are a couple of issues that > have sprung up which I can't seem to locate the answers for: > > 1) Exceptions - We have exposed our own object/funcs and so, would also > like to expose errors that our functions can generate as catchable > exceptions in JS. However, from looking at JSAPI.H we cannot see a clear > way to "throw" an exception from the host. We have tried to add entries to > JS.MSG and marked them as JSXN_ERR which seems to cause the exception object > to get generated in scope but alas nothing is catching in JS. Do we have to > actually construct JS script to do the throw then evaluate the script in > scope in order to get exceptions? > > 2) Object Lifetimes - To make the object model in JS coherent with our own > internal object model we allow the JS object to keep a "reference count" on > our internal object so that JS controls its lifetime. This works fine but > we notice that the GC is VERY lazy and will choose to keep objects alive > after they are clearly never going to be accessed again, waiting for > shutdown or mem threshold, e.g.: > > function foo() > { > var x = new SomeObject; > // x drops out of scope after func, never to be seen again but object > ref will remain > } > > The object does indeed get cleaned up at shutdown but we have a system that > may instantiate some fairly big footprint objects such as forms, databases, > recordsets, etc... Understanding that the GC reserves the right to > arbitrarily clean these objects is there some way we can get a callback > stating "object no longer in use by any call object" in lieu of a > JSFinalize() so that we can force the GC ourselves and prevent a rather > large uneeded working set? > > Any insight or pointers in the right direction would be helpful including > more searchable resources like this newsgroup. > > thanks, > Pete Diemert > > .