memorymanager/fastmm question/suggestion



Hi,

would it make sense to have a FastSetLength(str,length,blocksize) function, where blocksize is a 'hint' to fastmm for the blocksize to allocate/reserve.

the intent is, in a situation where you know you'll be appending data to a string up to a particular size, you could reserve enough space so as the string increases in length, it becomes an in-place realloc, instead of a possible move..

eg

FastSetLength(s,0,10000);
//now length(s)=0, but its actually has a 10k block of memory available.
//append data to the string. there should be no move.
for i:=1 to 9000 do s:=s+'x';

if you know what i mean..
if it needs more space, it would then be a normal move/realloc as required.

thoughts? would it be worthwhile?
.



Relevant Pages

  • Re: memorymanager/fastmm question/suggestion
    ... where blocksize is a 'hint' to fastmm for the blocksize to ... > allocate/reserve. ... in a situation where you know you'll be appending data ... > so as the string increases in length, it becomes an in-place realloc, ...
    (borland.public.delphi.language.basm)
  • Re: Strings
    ... When allocating memory, there is *always* the possibility that the allocation will fail ... and you will get a NULL pointer back. ... APpending data to a string is a very expensive operation. ...
    (microsoft.public.vc.mfc)