TempAlloc

Fawzi Mohamed fmohamed at mac.com
Sat Dec 6 00:37:02 PST 2008


On 2008-12-06 00:20:49 +0100, dsimcha <dsimcha at yahoo.com> said:

> As per a discusson on digitalmars.D about a month ago, I've created a temp
> space allocator for quickly allocating memory in a last in, first out manner.
>  Its main use is for allocating scratch space to be used within a function
> without introducing threading bottlenecks, etc.  I've released it as an alpha
> on scrapple.  I'm working on a major update to my statistics library (also on
> scrapple) and will dogfood this there when I'm done with the update.  I think
> that it's pretty useful, at least in number crunching-type code, in its
> current form as a library.  However, it might be even better if integrated
> into druntime and the core language to make it safer (it's pretty dangerous if
> used incorrectly) or cleaner to use (I've done the best I can here, but if I
> had some compiler support, I could automate some stuff that I make the 
> caller do.)
> 
> For the code, see
> http://dsource.org/projects/scrapple/browser/trunk/tempAlloc.  The code is for
> D2 only, but could probably be ported to D1 using Tango's thread-local storage.

I think that it could be useful to add an argument to to 
frameInit/free, in any case not just to speed things up, but to quickly 
catch mismatched init/free calls.

using GC.malloc in malloc for large requested sizes kind of defeats the 
stated purpose (and what makes superstack more difficult to use) of not 
being GC scanned, even if I understand the problem of either making 
bookkeeping more complicated or create potentially big holes in the 
stack...

Fawzi




More information about the Digitalmars-d-announce mailing list