comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: access / freeing memory
Date: 17 Jul 2002 06:22:07 +0100
Date: 2002-07-17T06:22:07+01:00	[thread overview]
Message-ID: <x7vptxn3p4w.fsf@pushface.org> (raw)
In-Reply-To: pan.2002.07.16.21.26.26.334707.1152@gmx.net

Jan Prazak <janp9@gmx.net> writes:

> 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?

On a typical host OS like Windows or GNU/Linux, the OS makes memory
available to a process (execution of a program) on request, in chunks
(usually called "pages", size depends on CPU and OS; perhaps
2kB). When the process dies, the OS just deletes all the allocated
pages. No need to chase pointers; just delete the pages[1].

On the other hand, your typical real-time OS (like say VxWorks)
doesn't manage memory in this way. If your program never stops
(perhaps it's an engine control system), you don't have to worry about
what the OS would do if it did (though you still have to worry, a lot,
about memory leaks). But if you are running unit tests and you forget
to return memory at the end of your program, it's gone (until you
reboot and wipe the slate clean, which might not be such a bad idea at
that!).

[1] There is a lot of detail omitted here!



  reply	other threads:[~2002-07-17  5:22 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
2002-07-17  5:22         ` Simon Wright [this message]
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