Board index » delphi » dynamic memory allocation and dynamic arrays-Help

dynamic memory allocation and dynamic arrays-Help

Okay, I've tried all the examples included on here as well as in the Tech
Info documents provided by Borland.  I keep getting EAccess errors and/or
stach overflow errors when I run the program.  It doesn't matter if i'm
running from Delphi or just running the standalone .exe file.  I've
turned off the integrated de{*word*81} and the problem still exists.  

Right now i've got...

const

        maxNum=500;
type
        TMyStuf=record
                stuf:array[1..maxNum] of single;
        end;
        PMyStuf=^TMyStuf;
var
        MyStuf:PMyStuf;

Begin
        New(MyStuf);
        Dispose(MyStuf);
End;

 

Re:dynamic memory allocation and dynamic arrays-Help


It now works fine on my system as well.  The problem is that the Maximum
Stack size was not set high enough in Projects/Options/Linker.

I would have thought that the max stack size would grow automatically
when enough memory is available.

On 14 Apr 1996, David Ullrich wrote:

Quote
> eric abrams <eabr...@blue.weeg.uiowa.edu> wrote:
> >Okay, I've tried all the examples included on here as well as in the Tech
> >Info documents provided by Borland.  I keep getting EAccess errors and/or
> >stach overflow errors when I run the program.  It doesn't matter if i'm
> >running from Delphi or just running the standalone .exe file.  I've
> >turned off the integrated de{*word*81} and the problem still exists.  

> >Right now i've got...

> >const

> >       maxNum=500;
> >type
> >       TMyStuf=record
> >               stuf:array[1..maxNum] of single;
> >       end;
> >       PMyStuf=^TMyStuf;
> >var
> >       MyStuf:PMyStuf;

> >Begin
> >       New(MyStuf);
> >       Dispose(MyStuf);
> >End;

>    Looks fine to me, runs fine when I try it. (Doesn't do much<g>.)
> How do you know that this is what's causing the error?

> --
> David Ullrich
> Don't you guys find it tedious typing the same thing
> after your signature each time you post something?
> I know I do, but when in Rome...

Re:dynamic memory allocation and dynamic arrays-Help


Quote
eric abrams <eabr...@blue.weeg.uiowa.edu> wrote:
>Okay, I've tried all the examples included on here as well as in the Tech
>Info documents provided by Borland.  I keep getting EAccess errors and/or
>stach overflow errors when I run the program.  It doesn't matter if i'm
>running from Delphi or just running the standalone .exe file.  I've
>turned off the integrated de{*word*81} and the problem still exists.  

>Right now i've got...

>const

>    maxNum=500;
>type
>    TMyStuf=record
>            stuf:array[1..maxNum] of single;
>    end;
>    PMyStuf=^TMyStuf;
>var
>    MyStuf:PMyStuf;

>Begin
>    New(MyStuf);
>    Dispose(MyStuf);
>End;

        Looks fine to me, runs fine when I try it. (Doesn't do much<g>.)
How do you know that this is what's causing the error?

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...

Re:dynamic memory allocation and dynamic arrays-Help


On Sun, 14 Apr 1996 15:04:34 -0500, eric abrams

Quote
<eabr...@blue.weeg.uiowa.edu> wrote:
>It now works fine on my system as well.  The problem is that the Maximum
>Stack size was not set high enough in Projects/Options/Linker.

>I would have thought that the max stack size would grow automatically
>when enough memory is available.

It doesn't grow, to help catch infinite recursion errors. Imagine
having a 100 MB swap file, an automatically growing stack, and an
infinite recursion bug...
--
Ray Lischner                              li...@tempest-sw.com
Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

Re:dynamic memory allocation and dynamic arrays-Help


Looks fine to me too...

1) If you are _sure_ that the error is with that particular routine:

- it could be that your compiler directives are not set to detect such
  things are range check errors or strict variable evaluation (check the
  compiler options for your project) or more likely it could be an error
  memory (check the memory settings for stacks etc.)

- My hunch would be to temporarily decrease maxNum to something like 1 or
  2, try to re-compile and re-run your programme and see if it works

2) If you are not sure that the problem is with that routine your could:

-  comment it out to check if the rest of the programme works

-  use dialog box statements such as:

      showmessage('Starting - Okay');
      new(myStuff);
      showmessage('New() - Okay');
      dispose(myStuff);
      showmessage('Dispose() - Okay');

 before   or after  each statement to check where the error appears

Good luck,

Rudi
--
My opinions are my own and do not in any way reflect
those of my employer.
-

Other Threads