linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Micha Feigin <michf@post.tau.ac.il>
To: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Re: Newbie question on malloc()
Date: Fri, 4 Jun 2004 02:44:57 +0300	[thread overview]
Message-ID: <20040603234457.GK2562@luna.mooo.com> (raw)
In-Reply-To: <20040603194251.GY20632@lug-owl.de>

On Thu, Jun 03, 2004 at 09:42:51PM +0200, Jan-Benedict Glaw wrote:
> On Thu, 2004-06-03 04:34:27 +0300, Micha Feigin <michf@post.tau.ac.il>
> wrote in message <20040603013427.GD2562@luna.mooo.com>:
> > On Wed, Jun 02, 2004 at 08:37:34PM +0200, Jan-Benedict Glaw wrote:
> > > Well, that all depends on the definition of "OS". Any recent 32+ bit
> > > operating system with virtual memory capabilities and multi-processing
> > > will reclaim malloc()ed RAM upon process termination.
> > 
> > It has nothing to do with virtual memory. In any multi-processing OS
> > (any modern one probably) memory allocations are done by the kernel
> > since the kernel is the one managing the system's memory.
> > 
> > If the kernel doesn't have a bug, this memory is released on process
> > exit (unless it is still used by another process such as with fork with
> > virtual memory where it is marked copy on write).
> 
> Read again. There ARE (or at least: were) operating systems that
> intentionally did *not* implicitely free memory. If an application
> missed to free all allocated memory, it's lost. Forever.
> 

Single process operating systems could get away with doing that. Multi
process operating systems (and most modern ones are) can't afford that
luxury as it will allow one misbehaving process to kill the system
(maybe win 3 could get away with that as it was a cooperative multi
tasking system as opposed to a properly scheduled one and dynamic memory
there was a very sick thing using handles)

Maybe some special purpose embedded systems will do that to reduce
overhead but they will be hard to find probably.

> But modern OSes (those with at least have the capabilities mentioned
> above) will automatically reclaim all of a exit'ed process' memory.
> 
> MfG, JBG
> 
> -- 
>    Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
>    "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
>     fuer einen Freien Staat voll Freier B?rger" | im Internet! |   im Irak!
>    ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));



  reply	other threads:[~2004-06-03 23:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-02 11:48 Newbie question on malloc() Wen Guangcheng
2004-06-02 17:08 ` John T. Williams
2004-06-02 17:41   ` Glynn Clements
2004-06-02 17:52     ` John T. Williams
2004-06-03  7:41       ` Glynn Clements
2004-06-03 11:32         ` Micha Feigin
2004-06-04  2:11           ` Glynn Clements
2004-06-04 12:31             ` Micha Feigin
2004-06-02 18:37     ` Jan-Benedict Glaw
2004-06-03  1:34       ` Micha Feigin
2004-06-03 19:42         ` Jan-Benedict Glaw
2004-06-03 23:44           ` Micha Feigin [this message]
2004-06-04  8:06             ` Jan-Benedict Glaw
2004-06-02 17:18 ` Glynn Clements
2004-06-03  1:28 ` Micha Feigin
2004-06-03  7:23   ` Luciano Moreira - igLnx
2004-06-03  7:59   ` Glynn Clements
2004-06-03 22:25     ` John T. Williams
2004-06-03 23:24       ` Paul Gimpelj
2004-06-04  0:14         ` John T. Williams
2004-06-04  2:35         ` Glynn Clements
2004-06-03 23:53       ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040603234457.GK2562@luna.mooo.com \
    --to=michf@post.tau.ac.il \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).