properties of the default STL allocator

Discussion in 'C++' started by Mark P, Apr 5, 2005.

  1. Mark P

    Mark P Guest

    Hi,

    I'm looking for some info on the default STL allocator, std::alloc. In
    particular, I'm wondering if it is optimized to handle many allocations
    of small objects. I'm thinking along the lines of a pool-based
    approach, for example.

    Any references would also be appreciated.

    Thanks,
    Mark
    Mark P, Apr 5, 2005
    #1
    1. Advertising

  2. Mark P wrote:
    > I'm looking for some info on the default STL allocator, std::alloc.


    You mean std::allocator, don't you?

    > In
    > particular, I'm wondering if it is optimized to handle many allocations
    > of small objects. I'm thinking along the lines of a pool-based
    > approach, for example.


    I don't think so. The Standard defines it as using '::eek:perator new'
    (see 20.4.1.1). There is a special "hint" argument, but beyond that
    the hint "may be used to help improve performance", the use of 'hint'
    is unspecified.

    I recommend you to look in the source for your library to see if it does
    utilise any particular scheme/approach.

    V
    Victor Bazarov, Apr 5, 2005
    #2
    1. Advertising

  3. Mark P

    Mark P Guest

    Victor Bazarov wrote:
    > Mark P wrote:
    >
    >> I'm looking for some info on the default STL allocator, std::alloc.

    >
    >
    > You mean std::allocator, don't you?


    Hmm, maybe I don't mean default STL allocator. My system appears to use
    the SGI STL implementation and according to the SGI docs, their default
    allocator is std::alloc. It hadn't occurred to me that this might be
    distinct from the default STL allocator.

    >
    > > In

    >
    >> particular, I'm wondering if it is optimized to handle many
    >> allocations of small objects. I'm thinking along the lines of a
    >> pool-based approach, for example.

    >
    >
    > I don't think so. The Standard defines it as using '::eek:perator new'
    > (see 20.4.1.1). There is a special "hint" argument, but beyond that
    > the hint "may be used to help improve performance", the use of 'hint'
    > is unspecified.
    >
    > I recommend you to look in the source for your library to see if it does
    > utilise any particular scheme/approach.
    >
    > V


    I looked into stl_alloc.h and there are comments such as, "We allocate
    memory in large chunks in order to avoid fragmenting the malloc heap too
    much." At the same time, I find these headers difficult to comprehend
    so I'm not sure if this does what I think it does.

    Mark
    Mark P, Apr 5, 2005
    #3
  4. Mark P wrote:
    > Victor Bazarov wrote:
    >
    >> Mark P wrote:
    >>
    >>> I'm looking for some info on the default STL allocator, std::alloc.

    >>
    >>
    >>
    >> You mean std::allocator, don't you?

    >
    >
    > Hmm, maybe I don't mean default STL allocator. My system appears to use
    > the SGI STL implementation and according to the SGI docs, their default
    > allocator is std::alloc. It hadn't occurred to me that this might be
    > distinct from the default STL allocator.


    Well... My fault. We should agree on using the same terminology, then.
    If you mean "the default *Standard* allocator", it's 'std::allocator'. If
    you don't meant the *Standard* allocator, but instead mean some old, and
    proprietary implementation of "Standard Template Library" (which, when was
    incorporated into the Standard Library, lost the 'STL' designator), then I
    can't help you, try talking to the proprietors of that implementation.

    The standard header <memory> contains several things, and 'std::allocator'
    template is one of them. Its implementation is not really governed by the
    Standard, but its interface and some basic stuff is. The description of
    them is in subclause 20.4 of the 1998 Standard (most likely the same in
    the newest edition as well).

    > [...]
    > I looked into stl_alloc.h and there are comments such as, "We allocate
    > memory in large chunks in order to avoid fragmenting the malloc heap too
    > much." At the same time, I find these headers difficult to comprehend
    > so I'm not sure if this does what I think it does.


    I wish I could help you with that...

    V
    Victor Bazarov, Apr 5, 2005
    #4
    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:
    456
  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:
    596
    Shane Beasley
    Aug 21, 2003
  3. Brian Genisio
    Replies:
    12
    Views:
    7,961
    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:
    688
    tom_usenet
    Feb 2, 2004
  5. Mark P
    Replies:
    1
    Views:
    527
    Mark P
    Apr 24, 2005
Loading...

Share This Page