comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic.brenta@tiscali.be>
Subject: Re: Please, help me.
Date: Sun, 07 Aug 2005 17:16:58 +0200
Date: 2005-08-07T17:16:58+02:00	[thread overview]
Message-ID: <87psspvkt1.fsf@tiscali.be> (raw)
In-Reply-To: 97GdnZ2dnZ1c-rnynZ2dnRqLa9-dnZ2dRVn-y52dnZ0@comcast.com

Jeff Creem <jcreem@yahoo.com> writes:
[...]
> If there is a set of large variables within the
>
> procedure blah is
>    large variables
>
> begin
>
> end;
>
> then moving all of the large variables to a package spec that the
> procedure blah withs will reduce the stack space.
>
> If it is the sum of lots of littler things through the program then
> perhaps using the storage_size attribute on a new task that does all
> of the real work of the program (with the main thread just
> terminating) will work.

I have observed that array or record aggregates tend to be allocated
on the stack, too.  Array aggregates are particularly surprising since
they're easy to replace with loops.  For example:

procedure Proc is
   type T is array (1 .. 100_000) of Integer;
   A : T;
begin
   A := (others => 42); 
end Proc;

allocates two large arrays on the stack (A and the aggregate) with
some compilers I've used.  In contrast:

procedure Proc is
   type T is array (1 .. 100_000) of Integer;
   A : T;
begin
   for J in A'Range loop
      A (J) := 42;
   end loop;
end Proc;

allocates just one array on the stack.

Back on topic, setting the stack size depends on the target operating
system and on the host linker.  There are even situations where it is
not possible to set the stack size at all.

-- 
Ludovic Brenta.



  parent reply	other threads:[~2005-08-07 15:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-05  0:55 STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW Adaddict
2005-08-05  1:21 ` Adaddict
2005-08-06 11:21 ` How to set the stack size on GNAT (Follow-up) Adaddict
2005-08-07 12:33   ` Please, help me Adaddict
2005-08-07 14:11     ` Jeff Creem
2005-08-07 14:51       ` Increasing stack size (was: Please, help me.) Larry Kilgallen
2005-08-07 15:16       ` Ludovic Brenta [this message]
2005-08-07 15:31   ` How to set the stack size on GNAT (Follow-up) John B. Matthews
2005-08-07 16:15   ` (Follow-up) Adaddict
2005-08-07 17:59     ` (Follow-up) Jeffrey Carter
2005-08-07 20:49       ` (Follow-up) Adaddict
2005-08-09 22:05 ` Follow up 2: raised STORAGE_ERROR : helper.adb:386 object too large Adaddict
2005-08-10  4:56   ` Jeff Creem
2005-08-10 17:44     ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1998-10-21  0:00 PLEASE HELP ME DENIS
1998-10-22  0:00 ` Tucker Taft
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox