K
karthikbalaguru
Hi,
Will 'free' return the memory Immediately to the OS ?
Thx in advans,
Karthik Balaguru
Will 'free' return the memory Immediately to the OS ?
Thx in advans,
Karthik Balaguru
karthikbalaguru said:Hi,
Will 'free' return the memory Immediately to the OS ?
Will 'free' return the memory Immediately to the OS ?
On Mon, 25 Feb 2008 01:10:49 -0800$B!$(Bkarthikbalaguru wrote$B!'(B
It depends on how your free() is implemented.
Most libc's use a complex algorithm to do memory manangement,
in order to get the speed, maybe they won't give the memory
to OS immediately after free().
karthikbalaguru said:Generally,
If it does not return the memory immediately, then ,
- Will it not drain the memory ?
- Will it not add more load to the OS in managing it by still being
in the memory(hidden) ?
- Will it not cause problems if i allocate some memory immediately
after calling free (as it is not freed immediately).
- Why do some memory management design return the memory immediately
to the OS and some at the later stage. Is there any specific
advantage in either of these designs ?
Hi,
Will 'free' return the memory Immediately to the OS ?
Thx in advans,
Karthik Balaguru
karthikbalaguru said:If it does not return the memory immediately, then , ....
- Will it not cause problems if i allocate some memory immediately
after calling free (as it is not freed immediately).
Will 'free' return the memory Immediately to the OS ?
karthikbalaguru said:Thx for your replies.
I agree on your view.
Interesting design followed by various OS .
I was thinking over this and have some queries based on this.
Generally,
If it does not return the memory immediately, then ,
- Will it not drain the memory ?
- Will it not add more load to the OS in managing it by still being
in the memory(hidden) ?
No.
- Will it not cause problems if i allocate some memory immediately
after calling free (as it is not freed immediately).
- Why do some memory management design return the memory immediately
to the OS and some at the later stage. Is there any specific
advantage in either of these designs ?
Interesting design followed by various OS . I was thinking over this and
have some queries based on this.
Generally,
If it does not return the memory immediately, then , - Will it not drain
the memory ?
- Will it not add more load to the OS in managing it by still being
in the memory(hidden) ?
- Will it not cause problems if i allocate some memory immediately
after calling free (as it is not freed immediately).
- Why do some memory management design return the memory immediately
to the OS and some at the later stage. Is there any specific advantage
in either of these designs ?
karthikbalaguru said:Thx for your replies.
I agree on your view.
Interesting design followed by various OS .
I was thinking over this and have some queries based on this.
Generally,
If it does not return the memory immediately, then ,
- Will it not drain the memory ?
- Will it not add more load to the OS in managing it by still being
in the memory(hidden) ?
- Will it not cause problems if i allocate some memory immediately
after calling free (as it is not freed immediately).
- Why do some memory management design return the memory immediately
to the OS and some at the later stage. Is there any specific
advantage in either of these designs ?
I think you are misunderstanding what freeing immediately actually
means. In fact the standard has nothing to say about when it is freed
and it could mean many things in many systems. I would guess that free
would remove the memory from the allocated list and add it to the free
list, at a minimum. This has to be done. Whether it also returns the
memory to the OS, i.e., shrinks the data segment of the process, is
totally implementation specific.
Hi,
Will 'free' return the memory Immediately to the OS ?
Vijay Kumar R. Zanvar said:No and yes, but usually no. The standard library implementation
may not release the acquired memory to the OS. However, the
program can not use it anymore once freed.
[/QUOTE]This has to be done. Whether it also returns the
memory to the OS, i.e., shrinks the data segment of the process, is
totally implementation specific.
Is it? I see nothing whatsoever in the definition of free which allows
for any implementation-defined behaviour; its behaviour, quite the
contrary, is absolutely and clearly defined, and *does not permit*
handing the memory back to the OS.
Kelsey said:[snips]
I think you are misunderstanding what freeing immediately actually
means. In fact the standard has nothing to say about when it is freed
and it could mean many things in many systems. I would guess that
free would remove the memory from the allocated list and add it to
the free list, at a minimum. This has to be done. Whether it also
returns the memory to the OS, i.e., shrinks the data segment of the
process, is totally implementation specific.
Is it? I see nothing whatsoever in the definition of free which
allows for any implementation-defined behaviour; its behaviour, quite
the contrary, is absolutely and clearly defined, and *does not permit*
handing the memory back to the OS.
According to your interpretation of the somewhat ambiguous phrase "madeKelsey said:The proper answer is that, according to the text of the standard, it
*cannot* return the memory to the OS; the definition of free simply does
not allow this.
According to your interpretation of the somewhat ambiguous phrase "made
available for further allocation".
It may be a reasonable interpretation, but it isn't definitive. SoRichard said:Ian Collins said:
....which is a perfectly reasonable interpretation, and one that I would
fully expect implementors to support. (Whether my expectations are
actually met in the Real World is an entirely different matter!)
Ian said:It may be a reasonable interpretation, but it isn't definitive. So
Kelsey's answer can't claim to be "The proper answer", merely one
possible answer.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.