STL custom allocator design

Discussion in 'C++' started by Dave Rahardja, Jan 31, 2007.

  1. 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
    Dave Rahardja, Jan 31, 2007
    #1
    1. Advertising

  2. Dave Rahardja

    Mark P Guest

    Mark P, Jan 31, 2007
    #2
    1. Advertising

  3. Dave Rahardja

    Alan Johnson Guest

    Dave Rahardja wrote:
    > 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

    --
    Alan Johnson
    Alan Johnson, Jan 31, 2007
    #3
  4. Dave Rahardja

    Guest

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

    Cheers, Henry

    --------
    http://hamath.blogspot.com - Science, technology, and interesting
    stuff Blog
    , Feb 1, 2007
    #4
  5. On 31 Jan 2007 20:09:21 -0800, "" <>
    wrote:

    >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
    Dave Rahardja, Feb 1, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan
    Replies:
    0
    Views:
    465
  2. =?ISO-8859-1?Q?Ralf_Schneewei=DF?=

    How to write an allocator for the STL List in VC++ 6.0

    =?ISO-8859-1?Q?Ralf_Schneewei=DF?=, Aug 20, 2003, in forum: C++
    Replies:
    2
    Views:
    603
    Shane Beasley
    Aug 21, 2003
  3. Brian Genisio
    Replies:
    12
    Views:
    8,037
    tom_usenet
    Jan 15, 2004
  4. Scott Brady Drummonds

    STL v. Norma" Memory Allocator

    Scott Brady Drummonds, Jan 30, 2004, in forum: C++
    Replies:
    5
    Views:
    695
    tom_usenet
    Feb 2, 2004
  5. Allen
    Replies:
    10
    Views:
    1,175
    James Kanze
    Jan 2, 2009
Loading...

Share This Page