comp.lang.ada
 help / color / mirror / Atom feed
* Multiple access to one object and deallocation
@ 2003-11-05 13:17 Harry Tucker
  2003-11-05 13:39 ` Marius Amado Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Harry Tucker @ 2003-11-05 13:17 UTC (permalink / raw)


My question is how to count references to an object so it will be 
deallocated only after all references have gone out of scope or set to 
null? An object reference could exist in several lists at any one time.

What I'm looking for is an easy way to catch my own coding errors so I 
don't bleed memory too much by overlooking a reference (access type).

Does anyone know if A# uses managed code? Since that would solve the 
issue through garbage collection. And then is pragma Controlled (ARM 
13.11.3) implemented to prevent automatic garbage collection/movement of 
an object if needed.

Harry
(When totally bored, 49, and retired, fight back! Writing a new mud in 
Ada just might do the trick.)




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple access to one object and deallocation
  2003-11-05 13:17 Multiple access to one object and deallocation Harry Tucker
@ 2003-11-05 13:39 ` Marius Amado Alves
  2003-11-05 13:52 ` Dmitry A. Kazakov
  2003-11-05 14:10 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Marius Amado Alves @ 2003-11-05 13:39 UTC (permalink / raw)
  To: comp.lang.ada

On Wed, 2003-11-05 at 13:17, Harry Tucker wrote:
> My question is how to count references to an object so it will be 
> deallocated only after all references have gone out of scope or set to 
> null? An object reference could exist in several lists at any one time.

This is often called "smart pointers" and often effected with storage
pools. There are examples out there.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple access to one object and deallocation
  2003-11-05 13:17 Multiple access to one object and deallocation Harry Tucker
  2003-11-05 13:39 ` Marius Amado Alves
@ 2003-11-05 13:52 ` Dmitry A. Kazakov
  2003-11-05 14:10 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2003-11-05 13:52 UTC (permalink / raw)


On Wed, 05 Nov 2003 07:17:39 -0600, Harry Tucker
<snagaghash@sonetcom.com> wrote:

>My question is how to count references to an object so it will be 
>deallocated only after all references have gone out of scope or set to 
>null? An object reference could exist in several lists at any one time.

If "out of scope" means that the access type gets out and if the
target type is controlled, then all allocated objects for which
Unchecked_Deallocation was not called will be destroyed (AARM 7.6.1).

If "out of scope" means an access object, then you need something like
smart pointers. For example:

http://www.dmitry-kazakov.de/ada/components.htm

>What I'm looking for is an easy way to catch my own coding errors so I 
>don't bleed memory too much by overlooking a reference (access type).

Well, let me put it so: reference counting eliminates some errors by
introducing new errors. (:-))

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple access to one object and deallocation
  2003-11-05 13:17 Multiple access to one object and deallocation Harry Tucker
  2003-11-05 13:39 ` Marius Amado Alves
  2003-11-05 13:52 ` Dmitry A. Kazakov
@ 2003-11-05 14:10 ` Preben Randhol
  2 siblings, 0 replies; 4+ messages in thread
From: Preben Randhol @ 2003-11-05 14:10 UTC (permalink / raw)


On 2003-11-05, Harry Tucker <snagaghash@sonetcom.com> wrote:
> My question is how to count references to an object so it will be 
> deallocated only after all references have gone out of scope or set to 
> null? An object reference could exist in several lists at any one time.

See: http://www.adapower.com/alg/smartp.html


-- 
"Saving keystrokes is the job of the text editor, not the programming
 language."



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-11-05 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-05 13:17 Multiple access to one object and deallocation Harry Tucker
2003-11-05 13:39 ` Marius Amado Alves
2003-11-05 13:52 ` Dmitry A. Kazakov
2003-11-05 14:10 ` Preben Randhol

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