comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: About a conditional garbage collection
Date: 1999/04/10
Date: 1999-04-10T00:00:00+00:00	[thread overview]
Message-ID: <m3lng1z28n.fsf@mheaney.ni.net> (raw)
In-Reply-To: 7elpap$9js$1@news1.bu.edu

ddutheza@bu.edu (ddutheza) writes:

> This may be a classical question in Ada, but I just start with the
> language, so please escuse any stupid questions.

The only stupid question is the one that doesn't get asked.

 
> To begin, is there a possibility to include a conditional garbage
> collector in any Ada95 collector. By this, I mean a garbage collection
> that could be activated or not depending on the real-time constraints
> of a project?

I guess it depends on what you mean by "garbage collection."  There is
no automatic garbage collector in the traditional sense, but what Ada does
is give you the programmer the tools you need to claim unused memory
automatically.

"Controlled" types in Ada automatically call operations during
elaboration, assignment, and finalization of a controlled object, which
can be used to reclaim garbage, or modify a reference-count.

So, for example, if I implement an unbounded stack as a controlled type,
I can reclaim the memory automatically when the stack object disappears.
So the garbage does indeed get collected.

I can even implement reference-counted lists this way.  During
assignment of a list object, a count of references to the list is
incremented automatically.

When list objects are finalized, the reference count is decremented
automatically, and when it goes to zero, the list is garbage collected.

For an example of a reference-counted list, and many other examples,
visit the ACM patterns archive.

<http://www.acm.org/archives/patterns.html>
<mailto:patterns@acm.org>

You can subscribe to the patterns list by sending the message (body)

subscribe patterns <your full name>

to the ACM mailing-list server.

<mailto:listserv@acm.org>


> To finish, Modula-3 is like Ada95 a powerful programming language that
> could be use to create modern operating systems. One big advantage of
> modula are the modules that can be loaded and unloaded at run time
> making memeory management easier. Does Ada95 possess something similar
> to a module?

Ada has a module; it's called a "package."  















  reply	other threads:[~1999-04-10  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-09  0:00 About a conditional garbage collection ddutheza
1999-04-10  0:00 ` Matthew Heaney [this message]
1999-04-12  0:00   ` ddutheza
replies disabled

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