Garbage collection in D

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Jun 4 02:32:20 PDT 2009


bearophile wrote:
> Rainer Deyke:
>> D's performance is unexpectedly bad, so much that I expect that it might be using dynamic memory allocation anyway despite the 'scope' keyword. Java is clever in that it eliminates unnecessary dynamic memory allocations automatically.<
> 
> I think Java here is doing a bit more than just removing the dynamic allocation. I don't think D (compiled with LDC) is doing doing any allocation here. I'll ask to the LDC IRC channel.

LDC actually still does a dynamic allocation there because it doesn't eliminate 
dynamic allocations in loops.
This is unfortunate, but I haven't yet had the time to figure out how to get the 
optimization passes to prove the allocation can't be live when reached again. 
(If multiple instances of memory allocated at the same allocation site may be 
reachable at the same time, it's not safe to use a stack allocation instead of a 
heap allocation)

It's on my to-do list, though.


More information about the Digitalmars-d-learn mailing list