Re: Doubts about free()
- From: Pawel Dziepak <pdziepak@xxxxxxxxxxx>
- Date: Fri, 31 Oct 2008 05:49:50 -0700 (PDT)
Assuming there is a need for memory by some other process and no other
free memory is available, is it the case malloc for the other process
would fail under such circumstances. Does the OS do some kind of
tracking and free up this memory. Is there any way to force freeing up
the memory to the system back.
I don't think that managing memory in that way is a program's job. You
just have to allocate memory (malloc) and release it (free). The
implementation specific details shouldn't bother you, unless you are
writing specialized program that requires good performance and uses
many resources.
In such kind of implementations which does not release pages of memory
allocated by the program, pages full of "empty and reserced" blocks
probably will be swapped, and there won't be any problems with
allocating memory for other processes.
If you want to get on the lower level of managing memory, you will
need to write your own implementation of malloc/free functions.
However, then you need to use platform dependent functions such as
sbrk in POSIX.
Pawel Dziepak
.
- Follow-Ups:
- Re: Doubts about free()
- From: vippstar
- Re: Doubts about free()
- References:
- Doubts about free()
- From: pushpakulkar
- Doubts about free()
- Prev by Date: Re: Doubts about free()
- Next by Date: Re: Judge the encode systm used by the file.
- Previous by thread: Re: Doubts about free()
- Next by thread: Re: Doubts about free()
- Index(es):
Relevant Pages
|