STL custom allocator design

D

Dave Rahardja

Where would I go to learn how to create a custom STL allocator? I want to
manage memory in a particular way for certain containers.

-dr
 
A

Alan Johnson

Dave said:
Where would I go to learn how to create a custom STL allocator? I want to
manage memory in a particular way for certain containers.

-dr

Josuttis has some sample code online from his book "The C++ Standard
Library - A Tutorial and Reference". Obviously the book would help to
put it all into context, but the sample code is straightforward and has
a lot of comments:
http://www.josuttis.com/libbook/memory/myalloc1.cpp.html
 
G

gamediaceo

What would be the benefit of creating a custom allocator for an STL
container?

Cheers, Henry
 
D

Dave Rahardja

What would be the benefit of creating a custom allocator for an STL
container?

In an embedded system that must contend with both long uptimes and small
amounts of memory, it is often beneficial to manage dynamic memory allocation
"by hand". I'd still like to use vector, string, etc., but I'd like to
constrain how the memory is allocated (e.g. from a pool or section of memory).

-dr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top