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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b99897135d6631cc X-Google-Attributes: gid103376,public Newsgroups: comp.lang.ada Subject: Re: memory management and productivity References: <40d15023$1_1@baen1673807.greenlnk.net> <2jnh22F12nvieU2@uni-berlin.de> <40d694da$1_1@baen1673807.greenlnk.net> From: Brian May X-Home-Page: http://snoopy.apana.org.au/~bam/ Date: Tue, 22 Jun 2004 08:36:41 +1000 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:la8ehhmPRi7ktEmut6mnftrn8eg= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: dsl-202-173-153-89.vic.westnet.com.au X-Trace: news.melbourne.pipenetworks.com 1087857401 202.173.153.89 (22 Jun 2004 08:36:41 +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!news2.google.com!news.maxwell.syr.edu!news.mel.connect.com.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:1752 Date: 2004-06-22T08:36:41+10:00 List-Id: >>>>> "Martin" == Martin Dowie writes: Martin> Not quite true! Try this... I think the finalize routine doesn't get called because the variable drops out of scope, it only gets finalized when the program exits. So you can't rely on this behavior unless your program was going to exit anyway. eg. change the Wibble function to: --- cut --- with Ada.Text_IO; use Ada.Text_IO; with Foo; procedure Wibble is procedure Wobble is B : Foo.Handle := new Foo.Bar; C : constant Foo.Reference := new Foo.Bar'(Foo.Default); begin Put_Line ("Wibble"); end Wobble; begin Wobble; Put_Line ("Wobble"); end Wibble; --- cut --- I get: --- cut --- Initialize Finalize Finalize Wibble Wobble Finalize Finalize --- cut --- Ada can't finalize B or C until the program exits, because these pointers might be duplicated to variables not in the same scope. When you use Free(...) you are telling the compiler that you guarantee this is not the case. -- Brian May