[Development] Qt 5.9's new garbage collector documentation? + root_ptr

Tim Blechmann tim at klingt.org
Sun Jul 16 01:21:06 CEST 2017


>>>> fwiw, to get this thread back to the main topic, i still fail to see
>>>> how
>>>> root_ptr deals with objects which are reachable from multiple roots,
>>>> which have independent lifetime
>>>
>>> Please provide an example.
>>
>> i've posted some already
> 
> I'm working on the parser right now but I thought I proved my point with
> the following code:
> 
> var temporary = 0;
> 
> var bar = function (object)
> {
>     return 10;
> };
> 
> var foo = function ()
> {
>     var object;
>     var result = function() { return object; };
>     return function() { return bar( object ); };
> };
> 
> for (var i = 0; i < 1000000; ++ i)
>     console_log((foo())(temporary));

after `foo` returns, you only have one root, as neither `result` nor
`object` will escape `foo` and `object` will only be referenced by the
closure returned by `foo`.

`result` is a perfect target for escape analysis. maybe even `object`.
you have read about escape analysis, right?




More information about the Development mailing list