Are there any good custom allocators for C ++ that maximize link locality?

I run a simulation with a lot if I link the original memory allocations to the object. Modeling should be done as quickly as possible, but distribution speed is not important. I'm not interested in liberation.

Ideally, the allocator will place everything in a contiguous block of memory. (I think this is sometimes called the arena?)

I cannot use a flattened vector because the selected objects are polymorphic.

What are my options?

+5
source share
7 answers

Just make your own.

Check out the old question to find out how to get started:

++?

+5

-, . . malloc (x) x , (x). ,

, , , . , reset , , .

- , , , . boost: pool . , x - - .

, , . Memory-PDF. , . , , , ,

+4
+2

- . : Lea, Robinson, Knowlton, Grunwald.

: , . , , , , : , , .

, , , ; ..

Foo *a = new Foo();
Bar *b = new Bar;
b == ((byte *)(a)) + sizeof(Foo);

, , , . , , , ; , .

+1

(MIT).

+1

C . , , , , .

+1
source

This is a pretty big thing, just take wikipedia . One specific example was in Alexandrescu's book and should be implemented in his Loki library . GCC also comes with several implementations std::allocator, just browse your distribution.

0
source

All Articles