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,ec2a500cce3658c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!irazu.switch.ch!switch.ch!newsfeed00.sul.t-online.de!t-online.de!frankfurt2.telia.de!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsc.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: sv, sv-se, sv-fi, en-gb, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Memory leak - What the ...? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Message-ID: Date: Tue, 12 Oct 2004 19:37:26 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsc.telia.net 1097609846 217.209.116.179 (Tue, 12 Oct 2004 21:37:26 CEST) NNTP-Posting-Date: Tue, 12 Oct 2004 21:37:26 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:5103 Date: 2004-10-12T19:37:26+00:00 List-Id: Marius Amado Alves wrote: >> Adjust is called just after the members of the record have been >> copied. So imagine you have >> >> A :=3D B; >> >> When Adjust(A) gets called, you will have >> >> A.Data =3D B.Data >> >> Since Data is an access type, you have a shallow copy where both A and= >> B have members pointing to the same heap space. >> >> In the Adjust, what A does is replicate the pointed data to get a new >> pointer and a deep copy where A and B point to different heap copies. >> >> Additionally, before A being overwritten, Finalize(A) is called just >> in case it needs to free some memory. >> >> Hope this helps. >=20 > Not really. The only way for leaking not to take place is for the old=20 > This.Data value being held somewhere. Where? In B, where it's been all the time. If B was a variable on the stack,=20 it's still there on the stack, and still points to the old copy of the=20 data. If B was itself on the heap, then obviously there's a pointer to B = somewhere, since it could be accessed and copied to A. That pointer is=20 still there, and still points to B, which in turn still points to the=20 old copy of the data. If B was a temporary object, then the compiler is=20 smart enough to finalize it after A has been adjusted (or else the=20 compiler is broken). --=20 Bj=F6rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu