From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,19ad05fdbf4e671f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Deallocating records with task type fields. Date: Mon, 12 Dec 2005 12:32:53 +0100 Message-ID: <439D5FE5.2030206@mailinator.com> References: <1134168554.826805.70690@g49g2000cwa.googlegroups.com> <1vb61utj75dws.gjbmfyig7vzz.dlg@40tude.net> <1134274006.711602.173280@g43g2000cwa.googlegroups.com> <1bjubyn0kl3cr.1l53b31tl59vw.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net hlBX8f7HuQjSzfO6ifff1w4XFFgyKXOwr0ZY+Dsdg7gfwA/Jo= User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en In-Reply-To: <1bjubyn0kl3cr.1l53b31tl59vw.dlg@40tude.net> Xref: g2news1.google.com comp.lang.ada:6847 Date: 2005-12-12T12:32:53+01:00 List-Id: 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).