[fpc-devel] ReallocMem & TotalAllocated: Round 2
Nikolai Zhubr
n-a-zhubr at yandex.ru
Wed Feb 17 22:15:51 CET 2010
13.02.2010 15:32, Marco van de Voort:
>> 2) GetHeapStatus.TotalAllocated sometimes return negative values, though
>> I haven't been able to prepare a reasonably small example yet (should I?)
>
> Please attach example programs to a bugreport. Thank you.
I've created a small self-consistent example, but something is wierd
with it. In order to reproduce the effect, put the example in a file
named 000.pas (with other filename misbehaviour might not trigger!),
compile with 2.4.0 (do not add any options to compiler) and run on
windows. Then (hopefully) you will see bogus TotalAllocated values:
4194281K <enter>
4194257K <enter>
4194233K <...>
4194208K
4194184K
4194160K
4194136K
4194112K
4194088K
4194064K
....
Please note that while the problem itself is quite stable, the example
is not. That is, if you insert or remove some code, change the filename
etc, then the example might just start work properly! (Maybe it is
alignment-related, not sure)
I haven't sent this to mantis yet. Please someone let me know if this
example is appropriate (or not).
Thank you.
Nikolai
------------------------- cut -------------------------------
{$mode delphi}
{$apptype console}
uses
SysUtils;
const
data: array [0.. 12] of integer = (9000, 1000, 9000, 12, 9000, 26,
9000, 74, 9000, 1, 2000, 9000, 1);
var
p: pointer;
i: integer;
begin
p := nil;
repeat
for i := low(data) to high(data) do
ReAllocMem(p, data[i]*4);
writeln((GetHeapStatus.TotalAllocated shr 10), 'K');
readln;
until false;
end.
------------------------- cut -------------------------------
More information about the fpc-devel
mailing list