std.allocator: nomenclature needed
Etienne Cimon via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 16 18:13:28 PDT 2015
On 2015-05-14 23:27, Andrei Alexandrescu wrote:
> Also, I need two more good names: one for what's now called "porcelain"
> - high-level typed interface for allocators, and one for "best of
> Beatles" (not defined yet) - a module collecting a number of canned good
> allocator designs by connecting together components.
This may sound like a request, but it's probably more of a direction.
I intended to start writing my D software on top of a ScopedPool stack.
I'll explain... It's a manual memory management strategy I devised
(invented) because I needed to optimize heavy use of
XML/Json/DOM/tree-based structures.
The idea is to allocate in the top-most pool of the caller and
de-allocate when the pool goes out of scope. A pool is nice because it's
meant to trash all the objects instantly, it's much faster and
efficient. Just like when a process crashes.
You simply use `alloc!T` instead of `new T`. The scope is created with
`auto pool = ScopedPool(1024*16);`, which basically allocates pools in
16kb increments. You can use `pool.freeze()` and then it will
temporarily pop the pool from the stack so that `alloc!T` uses the pool
one level lower. The lowest level is the GC.
Example:
https://github.com/etcimon/spd
Implementation source:
https://github.com/etcimon/memutils/blob/master/source/memutils/scoped.d
If you like the idea, let this be a permission to license it to Boost =)
More information about the Digitalmars-d
mailing list