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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c233446a6027f1ed X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-16 12:59:03 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!mango.news.easynet.net!easynet.net!feed.news.nacamar.de!newsfeed.freenet.de!news.freenet.de!not-for-mail From: Jan Prazak Subject: Re: access / freeing memory Date: Tue, 16 Jul 2002 21:59:35 -0100 Newsgroups: comp.lang.ada Message-ID: References: <%WHY8.1173$tt5.52024504@newssvr13.news.prodigy.com> <3D343EF9.3051A6C2@san.rr.com> User-Agent: Pan/0.11.2 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso885915 Content-Transfer-Encoding: 8bit X-Comment-To: "Darren New" NNTP-Posting-Host: 213.7.193.10 X-Trace: 1026849493 news.freenet.de 23733 213.7.193.10 X-Complaints-To: abuse@freenet.de Xref: archiver1.google.com comp.lang.ada:27159 Date: 2002-07-16T21:59:35-01:00 List-Id: On Tue, 16 Jul 2002 14:42:16 -0100, Darren New wrote: > Fred's program thinks it's allocated or not. It just tosses the whole > chunk of memory. (That's a little simplified, but you get the idea.) > I will come back to this topic (see below). >> What do you mean? Why should a FIFO be faster than a LIFO? Or do you >> mean something else by this. > > He means usually you can allocate a local variable with a > declare...begin...end (which allocates information on the CPU's stack) > rather than using "new" to allocate something and then specifically have > to free it up. He's basically comparing how you do variable-sized > objects in Ada to how you do variable-sized objects in C (which has no > variable-sized objects, so you have to use "new" (aka malloc) to > allocate them) or Java (which has all objects allocated from the heap, > so can't put them on the stack for efficiency). declare...begin...end is indeed a very useful feature, sometimes I use it even when it's not neccessary (just to make the code more readable) (and of course sometimes for exception handling), but declare..b..e will not help me with pointers. > You need to learn terms like "heap" and "stack" before a programming > tutorial in Ada is likely to make as much sense as it could. Languages > where the operation of the machine is completely and totally hidden from > the user (APL, BASIC, etc) don't need quite as many technical terms. Do you know some specific pages on the net, which would give me an overview? (I don't want to go into details, so an overview or a small introduction would be ok.) Now let me resume the memory allocation. When a program starts, the OS allocates a memory block (say 100 kb) for it, then the program starts to generate some sort of stack with pointers, and breaks the 100 kb limit, so the OS gives the program more memory, for instance 100 kb more. Then the program doesn't destroy the stack, but it could say "head := null;" or something, or resize the stack without destroying nodes etc. Then the program ends, and the OS frees all the memory (200 kb), maybe it goes through every byte and makes sure that it's not somewhere "marked" as used (I don't know how memory allocation works in detail.). Was this a good explanation, or am I still wrong in some points? Thanks, Jan