Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-08-27 01:41:44


--- Daryle Walker <dwalker07_at_[hidden]> wrote:
> On Monday, August 25, 2003, at 2:57 PM, Peter Dimov wrote:
> has-bugs/is-slow/plain-old-sucks? There can be an orthogonal need for
> a different allocator class, which no improvement on the default one
> can fix.
>
> In this case, the Java user is 100% screwed since they can't change the
> memory manager at all. Or at least, can't change the manager without
> changing it everywhere. (Allocator policies allow mix-and-match.)

I am glad that boost is not a Java library. :)
Don't get me wrong, boost is an amazing library.
I am learning from it every minute I look at it,
great job guys thank you.
However I was a bit shocked when I realized how
ignorant boost is about memory policies.
For instance boost::signals use std::vector<>,
but it doesn't care to do anything about the allocator parameter.
Some libraries would mix global new/delete calls with user defined
memory policies and all that under the covers and the list goes on and on.

I don't like the STL allocators too much but I'd like to
see a modern C++ library that has consistent and
clear memory policies.

Instead of having an allocator template parameter
for each class, perhaps we could design a global
memory management class that can be scaled horizontally
on the data type basis.
It will require some way to associate a user defined allocator
with data type.
Then we would need to define STL-style allocators that
will call the boost memory manager.

The boost memory policy could be along the lines:

1. All boost classes have to use boost::allocator<>
with STL allocators internally.
   std::vector<int, boost::allocator<int> >;

2. If a boost class needs to create an object it must call boost::mm.
    int *x = boost::getmm()->create<int>(1);
     ...
    boost::getmm()->destroy(x,1);

3. The user can customize memory policies for her class by calling regmm
    boost::getmm()->regmm( MyAllocator<MyClass>() );

IMHO, in terms of memory management, this simple
policy will make boost to look more like a C++ library not Java.

It doesn't provide the flexibility of STL allocators but it
does give the user some control over the memory.

Eugene

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk