home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Newsgroups: comp.lang.c
- Subject: Re: Problems freeing memory using "free"
- Keywords: malloc,free,panic.
- Message-ID: <1992Dec21.171523.18080@thunder.mcrcim.mcgill.edu>
- Date: 21 Dec 92 17:15:23 GMT
- References: <BzH3uB.KnI@ccu.umanitoba.ca>
- Organization: McGill Research Centre for Intelligent Machines
- Lines: 39
-
- In article <BzH3uB.KnI@ccu.umanitoba.ca>, ies@access.mbnet.mb.ca (Integrated Engineering Software) writes:
-
- > When is dynamically allotted memory using c(m)alloc freed after
- > calling "free"?
-
- By the time free returns, the memory has been freed and must not be
- accessed again. Most implementations will permit the memory to
- continue to exist for some indeterminate time after free() returns;
- some will even leave the former contents undisturbed for a while. You
- cannot depend on either of these.
-
- > Using os_view() on a SGI, I am able to monitor the RAM available
- > before a call to c(m)alloc and after a call to free(). The OS
- > indicates that the dynamic memory has been allotted from the
- > available RAM(a test problem) and but then does not release the
- > allotted memory even after a call to free.
-
- This makes it an OS question, and as such it really belongs in the
- appropriate OS-specific group, comp.sys.sgi or some such.
-
- Most UNIXish systems' implementations of malloc never return memory to
- the OS; memory being free simply means that it is available for further
- calls to malloc. Whether another call to malloc will allocate some or
- all of the same memory is implementation-dependent and cannot be
- counted upon either way.
-
- > The available RAM is critical for my app, but future malloc's will
- > allot memory from the swap space which I do not want to access.
-
- I'm not sure what the problem is here. If you allocated a block and
- freed it, and future mallocs don't return it, the system will push
- those pages to swap because you're not accessing them, thus letting you
- keep something else in-core instead. If future mallocs do return that
- same memory, no problem.
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-