comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@acm.org>
Subject: Re: Stack based allocation vs. Dynamic allocation
Date: 2000/05/31
Date: 2000-05-31T19:56:59+00:00	[thread overview]
Message-ID: <86og5m7aig.fsf@acm.org> (raw)
In-Reply-To: dale-B8D55E.22230631052000@news.rmit.edu.au

Dale Stanbrough <dale@cs.rmit.edu.au> writes:
> I've fixed the code, and added in a few extras. I have compared various
> variations of the code (in C and in Ada), the results follow... [...]

Note that the Ada versions is not really comparable with the C version
since you have array bound safety in Ada (I guess the compiler removed
the checks) and not in C.

I'm surprised the Ada heap version is faster than the C one since GNAT
calls the system malloc (hmmm it might be a GNU malloc vs Solaris
malloc issue if you're using FSU threads).

Also you can have more fun by having the size of the local array
variable being a function of i, since there is no C stack based
equivalent (GNU C has it as a language extension though).

The only problem with stack based allocation is in a 32 bits address
space multi threaded application context where you might have big
arrays, you have then an unsolvable problem with thread stack size.

On the software I'm working on, we had to move some stack based
(dynamic) array to the heap (with controlled types for automatic
deallocation) for this reason.

-- 
Laurent Guerby <guerby@acm.org>




  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 ` Aaro Koskinen
2000-05-31  0:00 ` Ray Blaak
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
2000-05-31  0:00   ` Dale Stanbrough
2000-05-31  0:00     ` Laurent Guerby [this message]
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 ` Jean-Pierre Rosen
replies disabled

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