Smart pointers instead of GC?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Feb 3 13:13:46 PST 2014


On Mon, Feb 03, 2014 at 12:52:53PM -0800, Adam Wilson wrote:
> On Mon, 03 Feb 2014 12:40:20 -0800, Dmitry Olshansky
> <dmitry.olsh at gmail.com> wrote:
[...]
> >I won't be surprised that half of current GC problems are because
> >it's simply too stupid as an allocator. I had some numbers that
> >I'd need to dig up were GC.malloc was ~2x slower then malloc even
> >with garbage collection disabled.
> >
> >With that said I'd focus on ref-counting somehow coexisting with
> >tracing GC. It doesn't go well at the moment - try creating
> >dynamic arrays of std.stdio.File (that is ref-counted).
> >
> 
> I will not defend the current GC, it is about as stupid as you can
> make one and still have a functioning memory management system. It
> implements exactly none of the optimizations recommended for
> Mark-Sweep GC's in the GC Handbook.
> 
> That said, I firmly believe that wholesale replacement of the GC is
> throwing the baby out with the bathwater. Effectively, the poor D GC
> implementation has become an excuse to launch a crusade against all
> GC's everywhere, never mind that Java and the .NET GC's are
> consistent examples of just how good GC's can actually be.
[...]

I vote for the wholesale replacement of the GC... with a better GC. :-P
Preferably one that is on par with modern Java GC's.

I agree that the GC phobia of some people is a little overboard. It's
what they need for their specific use case, but that doesn't really
apply in other use cases for D. (And I'm not convinced that ARC is the
be-all and end-all of memory management issues -- I've seen real-life
examples of ARCs gone horribly, horribly wrong, whereas had a GC been
used in the first place things wouldn't have gone down that route.)

Nevertheless, supporting both can't be a bad thing; after all, D is all
about choice (it's a breath of fresh air to *not* have to shoehorn every
square peg into the OO round hole, like you have to in Java), so having
the choice to *not* use the GC is a net improvement IMO, even if most D
users wouldn't care about the difference.


T

-- 
Маленькие детки - маленькие бедки.


More information about the Digitalmars-d mailing list