comp.lang.ada
 help / color / mirror / Atom feed
From: Jan Prazak <janp9@gmx.net>
Subject: Re: access / freeing memory
Date: Tue, 16 Jul 2002 21:59:35 -0100
Date: 2002-07-16T21:59:35-01:00	[thread overview]
Message-ID: <pan.2002.07.16.21.26.26.334707.1152@gmx.net> (raw)
In-Reply-To: 3D343EF9.3051A6C2@san.rr.com

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




  reply	other threads:[~2002-07-16 22:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-16  0:52 access / freeing memory Jan Prazak
2002-07-15 22:22 ` tmoran
2002-07-16 13:54   ` Jan Prazak
2002-07-16 11:51     ` Fabien Garcia
2002-07-16 22:59       ` Jan Prazak
2002-07-16 15:42     ` Darren New
2002-07-16 22:59       ` Jan Prazak [this message]
2002-07-17  5:22         ` Simon Wright
2002-07-17 21:36           ` Jan Prazak
2002-07-24  0:25       ` David Thompson
2002-07-23  6:15   ` Kevin Cline
2002-07-18 18:22 ` chris.danx
2002-07-19 13:32   ` Jan Prazak
2002-07-19 23:50     ` chris.danx
     [not found] <mailman.1026804243.16337.comp.lang.ada@ada.eu.org>
2002-07-19  1:42 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox