GC question

Ola Fosheim Grøstad via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 8 11:26:53 PST 2017


On Saturday, 4 February 2017 at 15:23:53 UTC, Adam D. Ruppe wrote:
> On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote:
>> - Automatic but conservative. Can leak at any time.
>
> All GCs are prone to leak, including precise ones. The point of 
> garbage collection is not to prevent leaks, but rather to 
> prevent use-after-free bugs.

No, the main point of GC is to prevent leaks in the case where 
you have circular references.

Precise GCs don't leak, by definition. If the object is reachable 
then it isn't a leak.

Now, you might claim that objects that provably won't be touched 
again should be classified as dead and freed and that this is a 
bug that exhibit the same behaviour as a leak (running out of 
memory). But it's really nothing like the leaks you experience 
with manual memory management (e.g. circular references 
preventing memory from being released in a reference counting 
management scheme)






More information about the Digitalmars-d-learn mailing list