comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr>
Subject: Re: Stack based allocation vs. Dynamic allocation
Date: 2000/05/31
Date: 2000-05-31T07:29:21+00:00	[thread overview]
Message-ID: <8h2f0h$nl1$1@wanadoo.fr> (raw)
In-Reply-To: dale-D70BFC.16062031052000@news.rmit.edu.au

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]


dale <dale@cs.rmit.edu.au> a �crit dans le message : dale-D70BFC.16062031052000@news.rmit.edu.au...
> A discussion at work left me claiming that stack based allocation
> was quicker than heap based allocation.
>
> A person wrote up a demonstration program that proved that this
> wasn't the case (at least for the experiment).
> [...]
>    for i in 0 .. N - 1 loop
>       declare
>          a : ints_Ptr := new ints;
>
>       begin
>          for j in a'range loop
>             a(j) := j;
>          end loop;
>
>          free (a);
>       end;
>    end loop;
> end;
>
A wild guess:
Note that in this example, you immediately reallocate an array of the same size that has just been deallocated. This means that the
lookup which is often cause of slow heap allocation will immediately find a perfect fit. This is certainly not representative of a
real program. Try running your test with random array sizes, then tell us the results...

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog






  reply	other threads:[~2000-05-31  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-31  0:00 Stack based allocation vs. Dynamic allocation dale
2000-05-31  0:00 ` Jean-Pierre Rosen [this message]
2000-05-31  0:00 ` Aaro Koskinen
2000-05-31  0:00 ` Ray Blaak
2000-05-31  0:00   ` Dale Stanbrough
2000-05-31  0:00     ` Laurent Guerby
2000-06-01  0:00       ` Matthew Woodcraft
2000-06-01  0:00         ` Laurent Guerby
2000-06-05  0:00     ` Robert Dewar
2000-05-31  0:00   ` Gisle S�lensminde
2000-05-31  0:00     ` Lutz Donnerhacke
2000-05-31  0:00       ` Gisle S�lensminde
2000-05-31  0:00     ` Aaro Koskinen
replies disabled

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