Code: Pascal [Select][+][-]type PntDouble = ^double; procedure TForm1.Button3Click(Sender: TObject);var P : PntDouble; V : QWord; S, i : integer;begin S:=SizeOf(Double); for i:=1 to 16 do begin GetMem(P, i*S); V:=MemSize(P); Memo1.Lines.Add(V.ToString); end;end;
Please note that aside from the notes regarding MemSize this code will leak memory. You should better use ReallocMem as that will properly either grow the allocated memory if possible or safely move it to a new, larger location. And don't forget a FreeMem at the end.
P.S. Memsize is a documented function https://www.freepascal.org/docs-html/rtl/system/memsize.html
MemSize returns the size of a memory block on the heap.
"Michael Van Canneyt @mvancanneyt · 4 months ago OwnerI tested on linux. The numbers are indeed different, which is of course a bug...Please file a bug report in the FPC source repository, so the behavior can be corrected.Once corrected, I will adapt the documentation accordingly."