Garbage Collector

Konstantin via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 15 11:53:07 PDT 2016


On Wednesday, 15 June 2016 at 17:02:11 UTC, rikki cattermole 
wrote:

> Higher level languages like Java have the benefit of using 
> pools and optimizing for this usage pattern, D does and will 
> never have this.
Why don't you want the same for D?

> Well if you really insist to have a String class don't be too 
> surprised for some reason it doesn't have the same performance 
> to say Java.
Some areas, like compiling, or producing HTML/XML/JSON documents, 
manipulate strings a lot.
Other areas, like GUI editors for sufficiently complex documents, 
or level editors for videogame, need to efficiently manipulate 
huge trees of assorted small objects, not necessarily strings.

> Aka don't go around creating/destroying classes a huge amount 
> unless you have rolled some form of memory management policy 
> such as reserving memory for the GC to use.
Yeah, that’s what I regularly do in C++ when I need to 
efficiently create/destroys many small objects. Sure, this 
typically leads to the best performance, e.g. because I can make 
the memory layout as cache friendly as humanly possible.
But not all projects need that. And even for very performance 
demanding apps, not all components of the app need that.
For such cases, a good GC (that just works well out of the box 
like .NET's GC does) can reduce development costs significantly.


More information about the Digitalmars-d mailing list