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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: 4 beginner's questions on the PL Ada Date: Fri, 09 Aug 2013 17:52:35 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> <878v0aee8i.fsf@VLAN-3434.student.uu.se> <87ob96cxm8.fsf@VLAN-3434.student.uu.se> <92c32083-74f2-4aaa-94cc-9c9e882bfdf4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 10 Aug 2013 00:52:36 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="da68e1c0dc00d4aa5d0283c494e3a17a"; logging-data="15941"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6siUNWc4/vikzar2Zz3Bo700bM6lI87I=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Cancel-Lock: sha1:t2bo61NY++4L4GSObc57A/4SAL8= X-Original-Bytes: 2878 Xref: number.nntp.dca.giganews.com comp.lang.ada:182926 Date: 2013-08-09T17:52:35-07:00 List-Id: On 08/09/2013 04:43 PM, Alan Jump wrote: > > So what you have shown here is a classic recipe for a memory leak. That > strikes me as poor code design in any language. I was given Java as a first > OO language, so maybe that's what spoiled me on memory reclamation, but I > still tried to avoid reusing variables unless I was absolutely certain that > what I was writing was going to remain in a limited scope. That is basically the pattern often used for pools of job tasks. The tasks run until the program ends (they check a protected object periodically to see if they should exit.) The idea is to have as many tasks as are needed for the maximum number of concurrent jobs, so a new task is allocated whenever there is a new job and no idle task to work on it. Each task is allocated and the access value discarded. The tasks, when idle, wait for work on a protected queue of jobs. This isn't a memory leak, since we want that many tasks to exist and don't need to access them through their access values. If we knew how many tasks we needed at start up we'd declare them in an array. -- Jeff Carter "Well, a gala day is enough for me. I don't think I can handle any more." Duck Soup 93