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,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-09 03:19:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!freenix!deine.net!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Array and memory usage Date: Sun, 9 Mar 2003 11:19:07 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1047208747 14814 129.241.83.78 (9 Mar 2003 11:19:07 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Sun, 9 Mar 2003 11:19:07 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:35085 Date: 2003-03-09T11:19:07+00:00 List-Id: 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; 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. I thought all the memory needed for an array would be claimed when the program started no matter if the array was filled or not. Is this correct or am I just being tricked by the program that measures the memory used by my program? If it is correct then it doesn't matter if I define my array as (1 .. 100) or (1 .. 10_000) as long as I don't initialize the strings. I can just add to User_Data a: type Used_Type is array (1 .. 1000) of Boolean; Used : Used_Type := (others => False); And then I don't need to add any linked list etc... to my small server. I use GNAT 3.14p on i386 Linux (Debian). Thanks in advance Prebene Randhol -- () Join the worldwide campaign to protect fundamental human rights. '||} {||' http://www.amnesty.org/