Hi Nikolay,
On 06/13/2016 01:25 PM, Nikolay Sivov wrote:
It's a good moment to think a bit about the design here. I don't think
you want to reuse IActiveScriptSite for all script engines you load. A separated object would allow better ref counting, would be cleaner and safer in my opinion. A quick test on Windows suggests that native does that.
Do you mean that engines ever used in IScriptControl lifetime should be kept around even though only one can be used at a time? I see that mshtml does that, keeping a list of hosts per window, but for mshtml the reason for that is not simply to reuse engine instances. Or should I simply create a single site per script control object?
See the attached test for why it needs to be a separated object. The reason for not reusing this object is that, although script engines should not use script site after being closed, there is no guarantee they won't keep references that would be released later. That said, you should keep reference only to current script site object in script control, but when you close a script engine, simply detach script site from script control and let usual COM rules control when it's freed.
Jacek