Ok habs hinbekommen ...
Hing wohl massgeblich am GetMem
Delphi-Quellcode:
var
PrimeGrid: array of Boolean;
implementation
{ TPrimeThread }
procedure TPrimeThread.CalcPrimes(EndNum: Int64);
var
NotAPrime, CurrPrimeCandidate: Int64;
begin
CurrPrimeCandidate := 0;
GetMem(PrimeGrid,EndNum+1);
SetLength(PrimeGrid,EndNum+1);
while (CurrPrimeCandidate < EndNum) do
begin
PrimeGrid[CurrPrimeCandidate] := True;
CurrPrimeCandidate := CurrPrimeCandidate + 1;
end;
PrimeGrid[1] := False;
CurrPrimeCandidate := 2;
while (CurrPrimeCandidate < EndNum) do
begin
if PrimeGrid[CurrPrimeCandidate] then
begin
NotAPrime := CurrPrimeCandidate * 2;
while NotAPrime <= EndNum do
begin
PrimeGrid[NotAPrime] := False;
NotAPrime := NotAPrime + CurrPrimeCandidate;
end;
end;
CurrPrimeCandidate := CurrPrimeCandidate + 1;
end;
end;
procedure TPrimeThread.Execute;
begin
CalcPrimes(300000000);
end;