From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: Deallocating records with task type fields.
Date: Mon, 12 Dec 2005 12:32:53 +0100
Date: 2005-12-12T12:32:53+01:00 [thread overview]
Message-ID: <439D5FE5.2030206@mailinator.com> (raw)
In-Reply-To: <1bjubyn0kl3cr.1l53b31tl59vw.dlg@40tude.net>
Dmitry A. Kazakov wrote:
> On 10 Dec 2005 20:06:46 -0800, Gene wrote:
>>In fact just for fun I also tried having the Listener call
>>Unchecked_Deallocation itself just before exiting (i.e. the task was
>>deallocating its own context!). And with GNAT running under both
>>Solaris and Windows it never caused a problem.
>
>
> Yes, AFAIK it works with GNAT.
Warning here: deallocating a task type in GNAT will silently leak memory
*unless* the task is already 'Terminated.
You can make a small test for yourself: if the task is terminated,
there's no memory leak. If it isn't, free won't fail but there's memory
leak. If you create lots of tasks this will be noticeable sooner or later.
So I don't think it is (or was, I tested this with 3.15p for the last
time) possible for a task to self-deallocate itself.
You need some kind of task manager who does something like:
loop
if T'Terminated then -- where T is some task access type
Free (T); -- Where free is unchecked_deallocation instance
end if;
delay 0.1;
end loop;
I would manage this transparently using finalization: on the record
instantiation the task would be registered with the manager; on
finalization the manager would be notified that the task needs being
freed. (For example, the manager could have a list of accesses to tasks
being terminated).
next prev parent reply other threads:[~2005-12-12 11:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-09 22:49 Deallocating records with task type fields Gene
2005-12-10 7:16 ` Jeffrey R. Carter
2005-12-10 11:45 ` Simon Wright
2005-12-10 14:10 ` Dmitry A. Kazakov
2005-12-11 4:06 ` Gene
2005-12-11 11:50 ` Dmitry A. Kazakov
2005-12-12 11:32 ` Alex R. Mosteo [this message]
2005-12-12 18:30 ` Pascal Obry
2005-12-13 10:22 ` Alex R. Mosteo
2005-12-12 22:03 ` Randy Brukardt
2005-12-11 5:02 ` Gene
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox