Garbage Collector?

bachmeier via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 28 09:03:18 PDT 2017


On Friday, 28 April 2017 at 15:23:18 UTC, H. S. Teoh wrote:

> you could save yourself the bug by writing:
>
> 	auto x = malloc(...);
> 	scope(exit) free(x);
> 	// ... however many pages of stuff you want, you don't have to
> 	// remember to write free() afterwards!
>
> Yes, D comes with a GC... doesn't mean you have to use it if 
> you don't want to, though!

I usually use the GC, so I have limited knowledge in this area. 
How common is this pattern in D code? Is it better than using 
reference counted structs? Is there any advantage to using the GC 
in this scenario?

I would like to add this info to the wiki (I don't seen it there).


More information about the Digitalmars-d mailing list