Board index » delphi » How do I overcome stack overflow error?

How do I overcome stack overflow error?

I am writing a program which contains an array [1..50] of records and
it needs to be able to hold at least [1..150] records but if I try to
increase the array size, I get a stack overflow error when I run it in
Turbo Pascal.  I desperately need to find away to fit this many
records into the array if anyone can help please e-mail me, e-mail me,
I'M DESPERATE!!!.  If it helps at all this is what my type section
looks like:

Type
        aword = packed array [1..20] of char;
        namerec = record
                first : aword;
                last : aword;
        end;
        statusrec = record
                suspend : boolean;
                day : integer;
                month : integer;
                year : integer;
        end;
        addressrec = record
                street : aword;
                city : aword;
                state : aword;
                zip : aword;
        end;
        boyrec = record
                name : namerec;
                master : boolean;
                grade : integer;
                address : addressrec;
                phone : aword;
                status : statusrec;
        end;
        boylist = array [1..50] of boyrec;

 

Re:How do I overcome stack overflow error?


I am writing a program which contains an array [1..50] of records and
it needs to be able to hold at least [1..150] records but if I try to
increase the array size, I get a stack overflow error when I run it in
Turbo Pascal.  I desperately need to find away to fit this many
records into the array if anyone can help please e-mail me, e-mail me,
I'M DESPERATE!!!.  If it helps at all this is what my type section
looks like:

Type
        aword = packed array [1..20] of char;
        namerec = record
                first : aword;
                last : aword;
        end;
        statusrec = record
                suspend : boolean;
                day : integer;
                month : integer;
                year : integer;
        end;
        addressrec = record
                street : aword;
                city : aword;
                state : aword;
                zip : aword;
        end;
        boyrec = record
                name : namerec;
                master : boolean;
                grade : integer;
                address : addressrec;
                phone : aword;
                status : statusrec;
        end;
        boylist = array [1..50] of boyrec;

Re:How do I overcome stack overflow error?


Quote
In article <5a2v46$...@camel5.mindspring.com> doon...@pipeline.com (Jack McAuliffe) writes:
>I am writing a program which contains an array [1..50] of records and
>it needs to be able to hold at least [1..150] records but if I try to
>increase the array size, I get a stack overflow error when I run it in
>Turbo Pascal.  I desperately need to find away to fit this many
>records into the array if anyone can help please e-mail me, e-mail me,
>I'M DESPERATE!!!.  If it helps at all this is what my type section
>looks like:
>Type
>        aword = packed array [1..20] of char;
>        namerec = record
>                first : aword;
>                last : aword;
>        end;
>        statusrec = record
>                suspend : boolean;
>                day : integer;
>                month : integer;
>                year : integer;
>        end;
>        addressrec = record
>                street : aword;
>                city : aword;
>                state : aword;
>                zip : aword;
>        end;
>        boyrec = record
>                name : namerec;
>                master : boolean;
>                grade : integer;
>                address : addressrec;
>                phone : aword;
>                status : statusrec;
>        end;
>        boylist = array [1..50] of boyrec;

What you need to do is..

        Type
            PBoyList = ^boyList;

then...

        Var
           list:  PBoyList;

        Begin
           New(list);
           with List^ do begin
              ...
           end;
           Dispose(list);  list := nil;    {maybe}
        End;

What you are doing here is to allocate the record dynamically, on the heap,
instead of trying to fit it into the stack.  In Windows 3.1, your global
variables, your stack, and your local-heap are all(!) crammed into one 64K
segment.

The maximum size of a block that you can allocate dynamically at one chunk is
about 63K.  If you're running into -that- then you have to use some more
advanced kind of data structure; basically a tree.

/mr/

Re:How do I overcome stack overflow error?


I am writing a program which contains an array [1..50] of records and
it needs to be able to hold at least [1..150] records but if I try to
increase the array size, I get a stack overflow error when I run it in
Turbo Pascal.  I desperately need to find away to fit this many
records into the array if anyone can help please e-mail me, e-mail me,
I'M DESPERATE!!!.  If it helps at all this is what my type section
looks like:

Type
        aword = packed array [1..20] of char;
        namerec = record
                first : aword;
                last : aword;
        end;
        statusrec = record
                suspend : boolean;
                day : integer;
                month : integer;
                year : integer;
        end;
        addressrec = record
                street : aword;
                city : aword;
                state : aword;
                zip : aword;
        end;
        boyrec = record
                name : namerec;
                master : boolean;
                grade : integer;
                address : addressrec;
                phone : aword;
                status : statusrec;
        end;
        boylist = array [1..50] of boyrec;

Re:How do I overcome stack overflow error?


I am writing a program which contains an array [1..50] of records and
it needs to be able to hold at least [1..150] records but if I try to
increase the array size, I get a stack overflow error when I run it in
Turbo Pascal.  I desperately need to find away to fit this many
records into the array if anyone can help please e-mail me, e-mail me,
I'M DESPERATE!!!.  If it helps at all this is what my type section
looks like:

Type
        aword = packed array [1..20] of char;
        namerec = record
                first : aword;
                last : aword;
        end;
        statusrec = record
                suspend : boolean;
                day : integer;
                month : integer;
                year : integer;
        end;
        addressrec = record
                street : aword;
                city : aword;
                state : aword;
                zip : aword;
        end;
        boyrec = record
                name : namerec;
                master : boolean;
                grade : integer;
                address : addressrec;
                phone : aword;
                status : statusrec;
        end;
        boylist = array [1..50] of boyrec;

Re:How do I overcome stack overflow error?


Quote
In article <5a2v46$...@camel5.mindspring.com> doon...@pipeline.com (Jack McAuliffe) writes:
>I am writing a program which contains an array [1..50] of records and
>it needs to be able to hold at least [1..150] records but if I try to
>increase the array size, I get a stack overflow error when I run it in
>Turbo Pascal.  I desperately need to find away to fit this many
>records into the array if anyone can help please e-mail me, e-mail me,
>I'M DESPERATE!!!.  If it helps at all this is what my type section
>looks like:
>Type
>        aword = packed array [1..20] of char;
>        namerec = record
>                first : aword;
>                last : aword;
>        end;
>        statusrec = record
>                suspend : boolean;
>                day : integer;
>                month : integer;
>                year : integer;
>        end;
>        addressrec = record
>                street : aword;
>                city : aword;
>                state : aword;
>                zip : aword;
>        end;
>        boyrec = record
>                name : namerec;
>                master : boolean;
>                grade : integer;
>                address : addressrec;
>                phone : aword;
>                status : statusrec;
>        end;
>        boylist = array [1..50] of boyrec;

What you need to do is..

        Type
            PBoyList = ^boyList;

then...

        Var
           list:  PBoyList;

        Begin
           New(list);
           with List^ do begin
              ...
           end;
           Dispose(list);  list := nil;    {maybe}
        End;

What you are doing here is to allocate the record dynamically, on the heap,
instead of trying to fit it into the stack.  In Windows 3.1, your global
variables, your stack, and your local-heap are all(!) crammed into one 64K
segment.

The maximum size of a block that you can allocate dynamically at one chunk is
about 63K.  If you're running into -that- then you have to use some more
advanced kind of data structure; basically a tree.

/mr/

Other Threads