Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > properties of the default STL allocator

Reply
Thread Tools

properties of the default STL allocator

 
 
Mark P
Guest
Posts: n/a
 
      04-05-2005
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      04-05-2005
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 ':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
 
Reply With Quote
 
 
 
 
Mark P
Guest
Posts: n/a
 
      04-05-2005
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 ':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
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      04-05-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
attaching an STL Allocator interface Mark P C++ 1 04-24-2005 10:18 PM
STL v. Norma" Memory Allocator Scott Brady Drummonds C++ 5 02-02-2004 09:42 AM
Idea for custom thread-safe STL allocator? Brian Genisio C++ 12 01-15-2004 03:41 PM
How to write an allocator for the STL List in VC++ 6.0 =?ISO-8859-1?Q?Ralf_Schneewei=DF?= C++ 2 08-20-2003 11:48 PM
[ANN] Thread-aware STL-compatible memory allocator Dan C++ 0 07-29-2003 08:06 PM



Advertisments