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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.85.201 with SMTP id ap9mr17309584icc.11.1407839341819; Tue, 12 Aug 2014 03:29:01 -0700 (PDT) X-Received: by 10.140.88.85 with SMTP id s79mr8260qgd.18.1407839341787; Tue, 12 Aug 2014 03:29:01 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h18no18729633igc.0!news-out.google.com!b3ni24360qac.1!nntp.google.com!j15no6490970qaq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 12 Aug 2014 03:29:01 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=20.132.64.141; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 20.132.64.141 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: A simple question about the "new" allocator From: sbelmont700@gmail.com Injection-Date: Tue, 12 Aug 2014 10:29:01 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:21677 Date: 2014-08-12T03:29:01-07:00 List-Id: On Tuesday, August 12, 2014 2:54:50 AM UTC-4, NiGHTS wrote: > With all default configurations using a typical Ada compiler, will the fo= llowing code run indefinitely without fail or will it eventually crash? >=20 Note that you are (intentionally or otherwise) using an 'anonymous allocato= r' for which the rules are much different, however as written it would stil= l eventually crash. Apart from the simple advice of just not using an allo= cator to begin with, I would expect the following to not leak any memory: procedure main is begin=20 loop=20 declare Test : access Positive :=3D new Positive; begin null; end; end loop;=20 end main;=20 But it seems hit or miss whether or not a given compiler does this in the a= dvised manner (mine doesn't seem to). On the other hand, this seems to wor= k more consistently: procedure main is type T (x : access Positive) is null record; begin=20 loop=20 declare Test : T (x =3D> new Positive); begin null; end; end loop;=20 end main; Of course, there is still no real advantage to any of this over just a regu= lar object. -sb