Why many programmers don't like GC?

welkam wwwelkam at gmail.com
Fri Jan 15 15:48:07 UTC 2021


On Friday, 15 January 2021 at 14:35:55 UTC, Ola Fosheim Grøstad 
wrote:
> On Friday, 15 January 2021 at 14:24:40 UTC, welkam wrote:
>> You can use GC with D compiler by passing -lowmem flag. I 
>> didnt measure but I heard it can increase compilation time by 
>> 3x.
>
> Thanks for the info. 3x is a lot
Take it with a grain of salt. I heard it long time ago so I might 
not remember correctly and I didnt measure it myself.

> improved with precise collection
Precise GC is slower than default GC.

> Making it use automatic garbage collection (of some form) would 
> be an interesting benchmark.

-lowmem flag replaces all* allocations with GC allocations so you 
can benchmark that

On Friday, 15 January 2021 at 14:59:18 UTC, Ola Fosheim Grøstad 
wrote:
> I think? Or maybe I am missing something?

A write barrier is a peace of code that is inserted before a 
write to an [object]. Imagine you have a class that has pointer 
to another class. If you want to change that pointer you need to 
tell the GC that you changed that pointer so GC can do its magic.
https://en.wikipedia.org/wiki/Write_barrier#In_Garbage_collection

> 3. Make slices and dynamic arrays RC.

Reference counting needs mutation. How do you define immutable RC 
slice that needs to mutate its reference count? Thats a unsolved 
problem in D.





More information about the Digitalmars-d-learn mailing list