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,d02eb5c33ac65d9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-09 09:49:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Array and memory usage Date: 09 Mar 2003 12:49:36 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <2397C8D4BA396B7A.ADB0E590CE8E5EAE.1C7AEC9AFCA7BE12@lp.airnews.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1047232176 24030 199.172.62.241 (9 Mar 2003 17:49:36 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 9 Mar 2003 17:49:36 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:35095 Date: 2003-03-09T12:49:36-05:00 List-Id: Preben Randhol writes: > John R. Strohm wrote: > > "Preben Randhol" wrote in message > > news:slrnb6m8mg.15o.randhol+news@kiuk0152.chembio.ntnu.no... > >> I was a bit puzzeled to see that if I do: > >> > >> type Str_Array_Type is array (1 .. 1000) of String (1 .. 800); > >> > >> type User_Data is > >> record > >> Name : Str_Array_Type; > >> Hostname : Str_Array_Type; > >> end record; > > > > This declares two types and NO instances of those types. > > > >> my program uses 800 bytes of memory, while if I only change the program > >> like this: > >> > >> type User_Data is > >> record > >> Name : Str_Array_Type := (others => (others => ' ')); > >> Hostname : Str_Array_Type := (others => (others => ' ')); > >> end record; > >> > >> then the program uses 2356 bytes. > > > > This declares the same two types and TWO (2) implicit instances of > > Str_Array_Type, namely, the aggregate constants. That's where the > > difference comes from. A good compiler will not do that, especially if the object is statically allocated. - Bob