Garbage collection in D

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Jun 2 18:44:46 PDT 2009


On Tue, Jun 2, 2009 at 8:40 PM, Diwaker Gupta <diwaker at floatingsun.net> wrote:
> I've just started to play around with D, and I'm hoping someone can clarify this. I wrote a very simple program that just allocates lots of objects, in order to benchmark the garbage collector in D. For comparison, I wrote the programs in C++, Java and D:
> C++: http://gist.github.com/122708
> Java: http://gist.github.com/122709
> D: http://gist.github.com/121790
>
> With an iteration count of 99999999, I get the following numbers:
> JAVA:
> 0:01.60 elapsed, 1.25 user, 0.28 system
> C++:
> 0:04.99 elapsed, 4.97 user, 0.00 system
> D:
> 0:25.28 elapsed, 25.22 user, 0.00 system
>
> As you can see, D is abysmally slow compared to C++ and Java. This is using the GNU gdc compiler. I'm hoping the community can give me some insight on what is going on.

D's GC is not nearly as well-developed as that of Java's, and its
performance is not that stellar.  Sorry, but you are not the first to
discover this by any stretch of the imagination.  (On a side note, I
have a feeling you and bearophile will get on famously.)

Also, benchmarking a GC against manual memory management doesn't do
much for you.  It's apples and oranges.  Though it is funny to see how
badly Java beats C++ there.


More information about the Digitalmars-d-learn mailing list