Sharing in D

Walter Bright newshound1 at digitalmars.com
Thu Jul 31 22:19:13 PDT 2008


Sean Kelly wrote:
> All that said, I believe it's entirely possible to write performance-critical code in D so long as the
> programmer is careful about memory allocation.  And as Walter has said before, because even
> malloc is not time-constrained the same goes for any use of dynamic memory--GCs just magnify
> the issue.  Server apps in Tango, for example, don't allocate any memory at all once initialization
> is complete.  This is why they tend to be so blisteringly fast.  It's also why Tango is designed the
> way it is--not always super-convenient for run of the mill apps programming, but quite scalable
> for high-end work.  By contrast, I'd argue that Phobos is the opposite.

I wrote a version of Empire (the game) in D that does no allocation at 
all. Therefore, the gc never runs and there is never any unbounded delay.

The gc is never going to pop up out of nowhere and sink your 
application. A gc only happens when you request memory from the gc. For 
the real time constrained section of code, the idea is to pre-allocate 
all the data you'll need first, then do no allocation within the 
critical section.

In fact, such critical code in C++ does this anyway because there are no 
bounded time constraints on C++ new either. C malloc has no bound 
constraints, either.



More information about the Digitalmars-d mailing list