[3/4] jscript: Fix various memory and reference count leaks.

Jacek Caban jacek at codeweavers.com
Thu Dec 31 09:42:46 CST 2009


On 12/31/09 1:17 PM, Rob Shearman wrote:
> 2009/12/30 Jacek Caban<jacek at codeweavers.com>:
>    
>> Hi Rob,
>>
>> Thanks for your work on jscript. Unfortunately fixing Valgrind on jscript is
>> not going to be easy. Most of your fixes are good, except clear_global part
>> and "jscript: Fix a circular reference caused by object and function objects
>> being able to have properties that are objects and functions." patch. I've
>> sent a test showing that Windows doesn't do that.
>>      
> I've resent the memory leak patch without the clear_global part.
>    

Thanks.

>> To fix it properly we need
>> to implement a garbage collector. I've designed it in the very early days of
>> jscript, but I never had time to implement it.
>>      
> That sounds like an excellent piece of work for someone interested in
> algorithms as opposed to the usual bug fixing. I don't think I have
> the time to follow through on this myself at the moment.
>
> I can see how this would work for solving the general problem of
> circular reference counts in jscript. However, I don't see how this
> helps for managing the lifetime of global objects. It seems that
> either the global constructors have state in which case they need to
> be around for as long as the script context is, while not holding a
> reference to the script context to avoid preventing it from dying, or
> they don't have any state in which case they can be constructed lazily
> and destroyed when the last reference is removed.
>    

The general idea is that script_ctx_t structure is treated just like 
other objects by garbage collectors. This way, if there are no 
references stored outside script engine, as soon as engine is closed, it 
will be released because all its references will be circular. 
script_ctx_t will have to be treated a bit differently than regular 
objects in practice, but it's an implementation detail.

Thanks,
     Jacek



More information about the wine-devel mailing list