D vs. ISRs (interrupt service routines) or Which D language features implictly allocate memory?

Gregor Richards Richards at codu.org
Fri May 4 23:31:24 PDT 2007


Forest Ray wrote:
> One of D's intended uses is systems level programming.  These tasks include implementing ISR (interrupt service routines).  Generally speaking it is a very bad idea to allocate memory within an ISR, unless your memory system is reentrant.  Many memory managers, especially in the embedded environment, are not reentrant.  What language features of D implicitly allocate or resize memory?  I assume dynamic arrays, associative arrays, splicing, and concatenation will, but what else?  Obviously "new" allocates memory, but that is an explicit request by the programmer, not an implicit request as a side effect of a D language feature.  It would be very useful to have the ability to tag a scope of code as "native" or "pure" or "some_better_keyword" so the D compiler would issue an error for any expressions or statements within that scope that implicitly allocate/resized memory.  Thoughts, comments?
> 
> Forest

'new', concatenation and adding elements to associative arrays allocate 
memory. Those are the only language features that do (AFAIK)

Of the ones you assumed did, notably splicing does not.

  - Gregor Richards



More information about the Digitalmars-d mailing list