Discussion:
project1.exe has stopped working
(too old to reply)
bok
2010-06-06 22:18:26 UTC
Permalink
I haven't used Delphi in a LONNNNNGGGG time.

Using Delphi 6 \Vista...

If I declare a million element array "myarray" locally in the
button1click procedure. I get a Windows error message "project1.exe
has stopped working". If, however, I declare "myarray" as a global no
such error occurs.

============Trivial Error producing Example=================
procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
myarray:array[1..1000000] of integer; //***Produces error on
execution***
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;

============Trivial Error Free Example==================
var Form1: TForm1;
a:array[1..1000000] of integer;
implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;

Is this a known issue with Delphi6 or Vista? Any solutions?

Thanks,
Bok
Jamie
2010-06-06 23:51:16 UTC
Permalink
Post by bok
I haven't used Delphi in a LONNNNNGGGG time.
Using Delphi 6 \Vista...
If I declare a million element array "myarray" locally in the
button1click procedure. I get a Windows error message "project1.exe
has stopped working". If, however, I declare "myarray" as a global no
such error occurs.
============Trivial Error producing Example=================
procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
myarray:array[1..1000000] of integer; //***Produces error on
execution***
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;
============Trivial Error Free Example==================
var Form1: TForm1;
a:array[1..1000000] of integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;
Is this a known issue with Delphi6 or Vista? Any solutions?
Thanks,
Bok
that's bad coding.. you have limited stack space which is where that huge
array is being stored. That array is looking for 2M bytes.. Use a
dynamic array instead if you really need that.
News Free
2010-06-29 21:05:08 UTC
Permalink
Try
myarray[z]:=z;
instead of
a[z]:=z;
bye and good luck...!
Post by bok
I haven't used Delphi in a LONNNNNGGGG time.
Using Delphi 6 \Vista...
If I declare a million element array "myarray" locally in the
button1click procedure. I get a Windows error message "project1.exe
has stopped working". If, however, I declare "myarray" as a global no
such error occurs.
============Trivial Error producing Example=================
procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
myarray:array[1..1000000] of integer; //***Produces error on
execution***
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;
============Trivial Error Free Example==================
var Form1: TForm1;
a:array[1..1000000] of integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x,z:integer;
begin
z:=0;
for x:=1 to 1000000 do
begin
z:=z+1;
a[z]:=z;
end;
end;
Is this a known issue with Delphi6 or Vista? Any solutions?
Thanks,
Bok
Loading...