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,345a8b767542016e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-14 19:20:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!wn2feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail From: "Steve Doiel" Newsgroups: comp.lang.ada References: <3c90af1e@news.starhub.net.sg> Subject: Re: memory leakages with Ada? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: NNTP-Posting-Host: 12.225.227.101 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1016162452 12.225.227.101 (Fri, 15 Mar 2002 03:20:52 GMT) NNTP-Posting-Date: Fri, 15 Mar 2002 03:20:52 GMT Organization: AT&T Broadband Date: Fri, 15 Mar 2002 03:20:52 GMT Xref: archiver1.google.com comp.lang.ada:21253 Date: 2002-03-15T03:20:52+00:00 List-Id: "Calvin Ow" wrote in message news:3c90af1e@news.starhub.net.sg... > Hi, > Has Ada got any memory leakage problems like that of C? > Especially with the use of Pragma calls to C? > I'll assume you read the other replies to your post. I would like to add that there are many cases in Ada where you don't need to use dynamic allocation when you would have to use dynamic allocation in C. For example, if you want to read a block of data that is preceded by a count that gives the amount of data, in Ada the code would be something like: nbBytes := GetNbBytes( dataSource ); declare dataBuffer : ByteBuffer( 1 .. nbBytes ); begin GetData( dataBuffer ); end; Where in C the code would look something like: nbBytes = GetNbBytes( dataSource ); dataPtr = (char *)calloc( nbBytes ); GetData( dataPtr ); free( dataPtr ); Disclaimer: I didn't compile either of the above code snippets above, and I seldom release memory I dynamically allocate in C (I usually allocate once and re-use for the life of the program for real-time systems), but you get the idea. With regard to the Pragma calls to C, in some cases you can use a buffer declared on the stack instead of dynamically allocating for that case as well, but when you can't I don't think you'll find Ada to be less succeptable to leaks. SteveD