GC vs Resource management.

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


Am 03.05.2014 17:20, schrieb "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>":
> On Saturday, 3 May 2014 at 15:10:43 UTC, Paulo Pinto wrote:
>> Easy, you already know that you don't need the node, just call the
>> dispose method, instead of marking for release.
>
> But you don't know unless you use RC or GC.

I am always speaking from the point of view of automatic memory 
management, be it RC, GC or compiler aided dataflow analysis.

 > Let's say you make a jungle.
> Lots of pointers to the tree root node. And you also don't want to wait
> with collection if you hold onto hardware resources (forcing perhaps
> lower resolution graphics if you are low on GPU resources).


If you mean you need to be sure that all references are gone from the 
graph, before doing a dispose() invocation, then yeah you need some form 
of RC, even with a GC.

However that doesn't mean that the developer/API client needs to care 
about it.

It is a matter of how the graph node construction is exposed to the 
clients. With proper a proper ADT that can be hidden from the API client.

Automatic resource management requires another type of thinking anyway.

--
Paulo




More information about the Digitalmars-d mailing list