[Fwd: basic_string<> - useless because of its poor performance]
Ulrich Drepper
drepper@redhat.com
Thu Jul 5 15:25:00 GMT 2001
Loren James Rittle <rittle@latour.rsch.comm.mot.com> writes:
> First of all, since the C++ library is allocating memory for strings
> using the standard malloc() interface, it should consider always
> starting and growing the allocation by pagesize instead of 1 after
> it may no longer use the fast allocator.
Wrong. Allocating pagesize bytes causes enormous fragmentation. All
allocators get memory in pagesize quantities from the OS. Then they
add there overhead, and the rest they provide to the user. I.e., an
implementation which adds to pointers for administration would have
pagesize+2*sizeof(void*) chunks which does not fit well in multiples
of pagesize bytes.
Always allocate pagesize-N*sizeof(void). Normally N==2 is OK, to be
absolute safe go with N==4. This is a tuning parameter.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
More information about the Libstdc++
mailing list