How to use D without the GC ?

Lance Bachmeier no at spam.net
Wed Jun 12 22:32:01 UTC 2024


On Wednesday, 12 June 2024 at 21:36:30 UTC, Dukc wrote:
> bachmeier kirjoitti 12.6.2024 klo 18.21:
>> You're splitting things into GC-allocated memory and manually 
>> managed memory. There's also SafeRefCounted, which handles the 
>> malloc and free for you.
>
> I suspect `SafeRefCounted` (or `RefCounted`) is not the best 
> fit for this scenario. The problem with it is it `malloc`s and 
> `free`s individual objects, which doesn't sound efficient to me.
>
> Maybe it performs if the objects in question are big enough, or 
> if they can be bundled to static arrays so there's no need to 
> refcount individual objects. But even then, you can't just 
> allocate and free dozens or hundreds of megabytes with one 
> call, unlike with the GC or manual `malloc`/`free`. I honestly 
> don't know if calling malloc/free for, say each 64KiB, would 
> have performance implications over a single allocation.

Why would it be different from calling malloc and free manually? 
I guess I'm not understanding, because you put the same calls to 
malloc and free that you'd otherwise be doing inside this and 
~this.


More information about the Digitalmars-d-learn mailing list