Re:Friendship ended with the garbage collector
by p_l on Friday August 27, 2021 @03:27AM
(#28325235)
And then you get some pretty hilarious pauses and stuttering because such naive refcount system suck on all metrics other than simplicity of code (and even that is arguable).
And despite what some people think, malloc/free are not O(1) free lunch.
Re:Friendship ended with the garbage collector
by zozbot234 on Friday August 27, 2021 @05:09AM
(#28325704)
You can use arenas for the cases where you really can't do without delayed/batched deallocation. But deterministic deallocation as provided by RC is a very good default for many cases, including where low-latency is a goal.
Re:Friendship ended with the garbage collector
by p_l on Friday August 27, 2021 @07:20AM
(#28326375)
RC is not deterministic. That's the whole thing - when you free a refcounted object, you do not deterministically know how long is it going to take, and on systems that try to avoid RC-induced pauses, you don't get to know when the memory is going to be released.
If you want to talk determinism, you need to actually invest into deterministic behaviour - something that either requires dropping dynamic memory allocation altogether, or tends to go for GC with known determinism guarantees (for example, IBM Metronome).
Re:Friendship ended with the garbage collector
by raverbashing on Friday August 27, 2021 @03:33AM
(#28325273)
Well, naive code is going to suck, be it RC or GC
> And despite what some people think, malloc/free are not O(1) free lunch
Of course. Be it through a GC allocator or not. If you're at the point where the allocator is giving you trouble then GC/RC is the least of your problems ;)
"Garbage collecting", so, you mean, you're leaving garbage around then? Why?
With RC you're acting on the deallocation as soon as you are allowed to. Sure, you don't need to actually deallocate at that time, but you're acting upon it.
"Oh but what about loops" well, you can work around those (and they are rare).
My point is not that GCs are not useful. My point is that there is a better way of dealing with allocations if you know your object is not used anymore and not just treating memory as infinite.