[fpc-devel] Support needed in understanding some heap.inc related stuff
lagprogramming at aim.com
Sun Sep 28 19:58:19 CEST 2014
Thank you for your answer. :) Now that you've answered, can you further respond to the following question: why is it needed to zero fill the memory allocated that exceeds the requested value?
a) "pointer:=allocmem(initialsize); reallocmem(pointer,increasedsize);". I don't see the benefits of the zero filled bytes that exceed the "initialsize" value at "pointer". Once you "reallocmem" to increase size you don't expect to have the additional space filled with zeros. This means that an attempt to somehow optimize code because of initial more than enough zero filling is something hard to believe in.
b) if your affirmation is right then for "bytepointer:=allocmem(sizeof(byte));" we would zero fill at least 3 or 7 times the necessary amount. At the moment I don't see nothing good at that. The closest thing that got into my mind was the arrays. For an unknown reason to me, yet(somebody please enlighten me) dynamic arrays are always zero filled. But even these arrays don't use allocmem. It was something that got me curious. Instead of allocmem, getmem&fillchar are used separately :) (see dynarr.inc fpc_dynarray_setlength). Somebody saw the bottleneck(waste, whatever you want to call it) with this allocmem situation.
So. Can you please further develop you answer according to this message.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel