[fpc-pascal] replacement of MARK and RELEASE function in free pascal

johanns at nacs.net johanns at nacs.net
Thu Jun 19 16:37:31 CEST 2014


On Thu, Jun 19, 2014 at 03:28:42PM +0200, Sven Barth wrote:
>On 19.06.2014 13:29, Karoly Balogh (Charlie/SGR) wrote:
>>So either you use mypointer:=GetMem(size); or GetMem(mypointer, size);
>>both are valid. If you need to allocate heap space for a record,
>>use New/Dispose, or GetMem(myptr, sizeof(Tmyrecord));
>
>I wouldn't use GetMem() in case of record pointers just in case a 
>managed type happens to be in there. Unlike GetMem() New() does 
>initialize those fields correctly. Alternatively one should use 
>Initialize(myptr^) after the call to GetMem().
>

I seem to remember being warned in the old days of Turbo 
Pascal not mix use of getmem()/freemem() and 
new()/dispose() within a program, due to differences in 
the memory allocation strategies.  Are there still any 
compatibility or efficiency/performance issues with 
alternating between these two families, or can the most 
simple or appropriate call be used interchangeably?  In 
other words, now that objects are so much more prevalent in 
Pascal code, should getmem() and freemem() be avoided?




More information about the fpc-pascal mailing list