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,5799fe4f91b50de X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit From: Brian May Newsgroups: comp.lang.ada Subject: Re: Possible Memory Leak References: Date: Tue, 23 Nov 2004 10:00:06 +1100 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:G8SHSP+cj12lA3H4HceUT4+7Dro= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1101164386 202.173.153.89 (23 Nov 2004 08:59:46 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news3.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!news1.optus.net.au!optus!news.mel.connect.com.au!news-north.connect.com.au!news.alphalink.com.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:6344 Date: 2004-11-23T10:00:06+11:00 List-Id: >>>>> "R" == R A Matthews writes: R> This ensures that the target of the assignment is adjusted, so R> Self is set correctly and gives the target its own copy of the R> referenced data. R> BUT the Standard says that the temporary variable need not be R> finalized, in which case the temporary's data is not R> deallocated and so we have a memory leak. Noone has responded - strange; I will bite. I don't claim to be any expert, and I don't claim to completely understand the problem either, but I suspect you are imagining a problem where no problem exists. The compiler will manage allocation and deallocation of temporary variables, as required for you. If in doubt, either print a message in each routine and see when it is executed, or look at the assembler code. In a previous post, I said: Arr(1) := Empty expands into: + Temp := Empty; -- shallow copy + Finalize(Arr(1)); + Arr(1) := Temp; -- shallow copy + Adjust(Arr(1)); This could also be written as: + Temp := Empty; -- shallow copy + Finalize(Arr(1)); + Adjust(Temp); + Arr(1) := Temp; -- shallow copy Where you can see that Temp is adjusted, and not finalised, but no memory leak occurs either. (disclaimer: I didn't check if this is what happens, however nobody accused me of getting it wrong either...). -- Brian May