comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Why people wants to complicate code with Ada.Unchecked_Deallocation?
Date: 27 Jul 2006 19:28:39 -0400
Date: 2006-07-27T19:28:39-04:00	[thread overview]
Message-ID: <wccirliocew.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: m28xmesls0.fsf@grendel.local

Simon Wright <simon@pushface.org> writes:

> I don't see how having a storage pool of your own affects the need for
> unchecked deallocation? If your user wants to return the memory to
> your special pool she still has to use deallocation!

If you have a lot of objects with similar lifetimes, you can put them
all together in one pool, and deallocate the whole pool at once,
at the appropriate time.  Presuming you have a storage pool type
that knows how to do that, of course.

This is sometimes safer than deallocating them one by one, because you
have fewer places where you need to worry about "when is it safe to
deallocate?", and because you can't forget to deallocate some of the
individual objects.  It sometimes less safe, though, because you might
throw the baby out with the bathwater.  It depends on the program.

It's a very efficient way to manage storage.  Allocation can be just a
few instructions per object, and deallocation can be a small fraction of
one instruction per object.

- Bob



  reply	other threads:[~2006-07-27 23:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-26 19:34 Why people wants to complicate code with Ada.Unchecked_Deallocation? fabio de francesco
2006-07-26 19:51 ` Georg Bauhaus
2006-07-26 19:56 ` Simon Wright
2006-07-26 21:28 ` Jeffrey R. Carter
2006-07-27 15:49   ` adaworks
2006-07-27 19:11     ` Jeffrey R. Carter
2006-07-27 22:52     ` Simon Wright
2006-07-27 23:28       ` Robert A Duff [this message]
2006-07-27  0:07 ` Peter C. Chapin
2006-07-27 11:54 ` gautier_niouzes
replies disabled

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