Discussion:
IActiveScript object not released after an error - what causes it ?
(too old to reply)
R.Wieser
2020-05-11 09:12:36 UTC
Permalink
Hello all,

I've created a small program using IActiveScript (and friends), which works
well enough - all the objects seem to be released when the last 'Release's
are called.

The problem is that when the script contains an error (and the
'OnScriptError' method is called) the program ends with IActiveScript still
having a refcount of 1. :-(

The MSDN webpage on the 'OnScriptError' doesn't mention anything about it
and I've been unable to figure out where that refcount is added / not
removed.

As such I could do with a bit of help ...

Regards,
Rudy Wieser
R.Wieser
2020-05-11 12:44:38 UTC
Permalink
Post by R.Wieser
The problem is that when the script contains an error (and the
'OnScriptError' method is called) the program ends with IActiveScript
still having a refcount of 1. :-(
I did not follow rule one: Remove as much as you can while still stuill
generating the error (removing 'cruft' makes it easier to spot the cause)

It turned out that just parsing the script but not even running it still
caused the problem to appear, and I noticed, in the now way smaller logfile,
that the ScriptSite object was never released. After some head-scratching
I decided to call SetScriptState with SCRIPTSTATE_CLOSED, which seemed to
have done the trick: The ScriptSite objects 'Release' was called, which
(ofcourse) called the same for its parent.

A new thing popped up though : For some reason the 'AddNamedObject' object
is given another release too, causing it to clean itself up. I thought
that I had to do that myself, as I created it ...

One problem down, another takes its place. Oh well. :-)

Regards,
Rudy Wieser

Loading...