comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
To: "comp.lang.ada mail to news gateway" <comp.lang.ada@ada.eu.org>
Subject: Re: Allocating Memory with "new"
Date: Fri, 25 Apr 2003 07:46:43 -0500
Date: 2003-04-25T07:46:43-05:00	[thread overview]
Message-ID: <mailman.13.1051274855.13478.comp.lang.ada@ada.eu.org> (raw)


----- Original Message -----
From: "Peter Richtmyer" <prichtmyer@yahoo.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Friday, April 25, 2003 5:33 AM
Subject: Re: Allocating Memory with "new"


> "Vincent Smeets" <No.Spam@localhost> wrote in message
news:<3ea8d041$0$4083$4d4ebb8e@read.news.de.uu.net>...
>
> > Every time an access type comes out of scope, the memory allocated by
that
> > access type can be freed (garbage collection).
>
> Thanks - that certainly explains it. I thought the programmer had
> complete control of the memory allocated and that it would not be
> freed until an Unchecked Deallocate (or the program ended).
>
>From the addresses allocated, it looks like the allocation was done on the
stack, instead of the heap.  The compiler is free to do this, given that
Mem_Block_Ptr is declared on the stack.

Thus, this is not "garbage collection," but simply the fact that the
allocated memory goes out of scope when the procedure returns.

In this sense, the Rational compiler is "smarter" than GNAT, since
allocation on the heap is more expensive than allocation on the stack.

Incidentally, setting Mem_Block_Ptr to null is unnecessary, since
the rules of Ada require access objects to be initialized to null.

David




             reply	other threads:[~2003-04-25 12:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-25 12:46 David C. Hoos [this message]
2003-04-25 22:19 ` Allocating Memory with "new" Peter Richtmyer
  -- strict thread matches above, loose matches on Subject: below --
2003-04-24 19:30 Peter Richtmyer
2003-04-25  6:05 ` Vincent Smeets
2003-04-25 10:33   ` Peter Richtmyer
2003-04-25 15:09 ` Stephen Leake
replies disabled

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