comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Memeory management
Date: Mon, 05 Sep 2005 16:43:25 -0500
Date: 2005-09-05T16:43:25-05:00	[thread overview]
Message-ID: <naidnWP4ToNgJoHeRVn-2g@comcast.com> (raw)
In-Reply-To: 1125951895.357358.320220@o13g2000cwo.googlegroups.com

>wonder that are there any constrains on the memory allocated for
>variable declaraions? However, I did not allocate and deallocate memory
>as I did in C, does Ada provide automatically garbage collection?
  A particular Ada compiler, with a particular set of compile options,
and a particular OS, and a particular target machine, will of course
have some particular memory limitation.  How much memory do you need?
  If you declare variables in the ordinary way, e.g.
    procedure P(N : Positive) is
      Vector : array(1 .. N) of Integer;
      Bigger_Vector : array(1 .. 5*N) of Integer;
      Var1, Var2 : Float;
    begin
Ada will automatically allocate space for Vector, Bigger_Vector, Var1, and
Var2 at the beginning and deallocate on exit.
  If you allocate explicitly from the heap using access types (pointers)
and "new" then the Ada specification does not say whether the
implementation must do automatic garbage collection or not.  Most don't,
so you would need to explicitly use Ada.Unchecked_Deallocation to do your
deallocations.  (Many Ada applications are real time and it would be be
Bad if your train control program started doing extensive garbage
collection just when a sensor detected an obstacle on the track.)



  reply	other threads:[~2005-09-05 21:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-05 21:02 Memeory management Zheng Wang
2005-09-05 21:43 ` tmoran [this message]
2005-09-22 15:23   ` adaworks
2005-09-22 17:11     ` Martin Krischik
2005-09-05 21:45 ` jimmaureenrogers
2005-09-06 16:45 ` Martin Krischik
replies disabled

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