GC vs Resource management.

Paulo Pinto via Digitalmars-d digitalmars-d at puremagic.com
Sat May 3 08:10:45 PDT 2014


Am 03.05.2014 16:43, schrieb "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>":
> On Saturday, 3 May 2014 at 14:31:59 UTC, Paulo Pinto wrote:
>> - Make all scene graph nodes IDisposable.
>>
>> - Have a using(rootNode) {} on your render loop
>
> That would work for a static scene.
>
> But you want to mark resources ready for release when nodes are removed
> from the graph dynamically. In most cases shared pointers (ref counting)
> would work, but if you allow "fractal" recursion then you will get
> cycles. (e.g. meshnode->scaleRND->rotateRND->stopIfTooSmall->meshnode )

Easy, you already know that you don't need the node, just call the 
dispose method, instead of marking for release.

Cannot release right away? Place them in a "to be removed" queue and do 
the cleaning in a specific controlled point.

--
Paulo


More information about the Digitalmars-d mailing list