In article <bl248t$nj9$1@bob.news.rcn.net>,
tdineen@erols.com says...[color=blue]
> Ron,
> Thanks for the feedback. What I was looking for was more along the lines of
> a separate pool object, i.e. memory manager, that would handle the memory
> allocation for all the objects. Rather than having to ask the o.s for
> additional memory, it (string, list, etc) would get it from the pool
> object. If the pool object didn't have enough, it would then have to
> reallocate. Once the string, list, etc were done with the memory, it would
> get returned to the pool object.[/color]
There's nothing in the standard to mandate behavior like this, but it's
a fairly accurate description of how things _usually_ work. The
containers in the standard library allow the user to specify an
allocator object that will be used to allocate memory for the
collection. The default allocator will use new and delete to allocate
and free memory.
Since it's not observable behavior (in the way "observable" is meant by
the standard) there's no requirement that new and delete allocate large
chunks of memory from the OS, and sub-allocate out of those. In fact, I
know of one version of one compiler that _did_ use OS calls every time
you allocated or freed memory -- that's a rare (and long-since obsolete)
exception though. Simple market pressure prevents it from becoming
common; nearly everybody has at least a few competitors, and speeding up
the default new and delete will give a competitor a substantial
improvement in both benchmark scores AND in real speed, so most try to
make it at least pretty good (though if it becomes an issue, there are
after-market memory managers that might be worth looking into).
--
Later,
Jerry.
The universe is a figment of its own imagination.