GC vs. Manual Memory Management Real World Comparison

Johannes Pfau nospam at example.com
Wed Sep 5 10:31:08 PDT 2012


Am Wed, 05 Sep 2012 13:03:37 +0200
schrieb Benjamin Thaut <code at benjamin-thaut.de>:

> I rewrote a 3d game I created during my studies with D 2.0 to manual 
> memory mangement. If I'm not studying I'm working in the 3d Engine 
> deparement of Havok. As I needed to pratice manual memory management
> and did want to get rid of the GC in D for quite some time, I did go
> through all this effort to create a GC free version of my game.
> 
> The results are:
> 
>      DMD GC Version: 71 FPS, 14.0 ms frametime
>      GDC GC Version: 128.6 FPS, 7.72 ms frametime
>      DMD MMM Version: 142.8 FPS, 7.02 ms frametime
> 
> GC collection times:
> 
>      DMD GC Version: 8.9 ms
>      GDC GC Version: 4.1 ms
> 
> As you see the manual managed version is twice as fast as the garbage 
> collected one. Even the highly optimized version created with GDC is 
> still slower the the manual memory management.
> 
> You can find the full article at:
> 
> http://3d.benjamin-thaut.de/?p=20#more-20
> 
> 
> Feedback is welcome.

Would be great if some of the code could be merged into phobos,
especially the memory tracker. But also things like memory or object
pools would be great in phobos, an emplace wrapper which accepts a
custom alloc function to replace new (and something similar for delete),
etc. We really need a module for manual memory management (std.mmm?).
And functions which currently use the GC to allocate should get
overloads which take buffers (Or better support custom allocators, but
that needs an allocator design first).


More information about the Digitalmars-d-announce mailing list