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:09:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Re: Array and memory usage Date: Sun, 9 Mar 2003 17:09:16 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: References: NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1047229756 24785 129.241.83.78 (9 Mar 2003 17:09:16 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Sun, 9 Mar 2003 17:09:16 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:35094 Date: 2003-03-09T17:09:16+00:00 List-Id: Jeffrey Creem wrote: > > I believe what you are seeing is not something that will happen under all > OS's. > > Linux uses a commit-on-us type memory manager. Even though you initialized > your data, it probably was done in such a way that the memory was intialized > within the ELF initialized data segment. > > Under linux even something like > > aa = malloc(A_BIG_NUMBER) > > will not show all of the data as actually allocated until a process accesses > each page of memory.. > > What you are seeing is partially a trick and partially real. It is not a > direct effect of the language or compiler. > > Whether or not you should write your programs to rely on it will depend on > many factors. > > Certainly on an embedded OS like vxWorks, your memory would be allocated and > consumed immediately. OK Thanks for clearing it up. I saw the effect last night so I decided it was time for sleep as I thought I had done something else wrong. But when I saw the same effect today I started wondering what the effect was. At any rate I think I'll stick with an array and set it to some number that can be changed if needed. We are not talking about a lot of bytes anyway :-) -- () Join the worldwide campaign to protect fundamental human rights. '||} {||' http://www.amnesty.org/