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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b353437b73507a5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Jano Newsgroups: comp.lang.ada Subject: Re: Basic program with tasks goes out of memory Date: Fri, 06 Aug 2004 10:54:19 +0200 Message-ID: <2ngv8lFnp34U1@uni-berlin.de> References: <5ad0dd8a.0408050655.355fa926@posting.google.com> <2nf4m2F7cpkU1@uni-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de GhMQcz3od9TmUNH4+1EYPAonJXKU0ud+da4lTTHuQhk0Fjp+c= User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) X-Accept-Language: en-us, en In-Reply-To: <2nf4m2F7cpkU1@uni-berlin.de> Xref: g2news1.google.com comp.lang.ada:2598 Date: 2004-08-06T10:54:19+02:00 List-Id: Marc A. Criley wrote: > "Wojtek Narczynski" wrote: > > >>Any idea why this program (extracted from AdaSockets example) >>eventually eats up all RAM? Runtime leak or my ignorance? > > > > > Dmitry's fix should take care of your problem. But if you're using Gnat (and maybe other?) be sure to check that The_Task'Terminated is true before freeing. Otherwise the call will nullify your access but not free the task memory. So instead of a single delay you may prefer -- Inner loop: loop if Dummy'Terminated then Free (Dummy); exit; else delay 0.01; -- To not hog CPU end if; end loop; However I don't know if a task with a select-terminate clause can be never in 'Terminated state (realistically, before program finalization) if the other entries are callable. It works with tasks which reach their end-of-code (as your example after Start is called). The above isn't a problem for tasks allocated eventually to perform some job and then be freed. They should run until completion and then your polling task would take care of freeing the resources, no select-terminate involved.