Re: free - The Memory is still not returned back to OS
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Feb 2008 14:41:32 +0100
karthikbalaguru wrote:
On Feb 25, 4:30 pm, David Brown <da...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
badal_akr wrote:"free" can be implemented in many ways, depending on the OS (if any) andHi,If free does not return the memory to OS then look at the implementation
If the 'free' does not return the memory back to the OS, then what is
the advantage of it. Will it not drain the memory in certain
scenarios ?
Why does free' of certain OS return the memory back to OS while others
do not ?
Thx in advans,
Karthik Balaguru
of the free and ask the free,s developper.
the library. It is not uncommon for there to be a "cache" of heap
between the application level and the operating system. Thus when the
application asks for more memory (i.e., calls malloc() or a related
library function), it may get memory from this cache without needing an
OS call. If this cache does not have enough spare memory, the library
function will ask the OS for more. When freeing memory, the application
calls free() which returns the memory to the cache - the library
functions will only return the memory to the OS when an entire block is
unused (and it may not return it even then). Such a strategy can reduce
fragmentation in the main memory, it can improve data locality, and it
can allow the main OS memory manager and the library (or
application-level memory manager) to have different allocation schemes.
It is also quite possible to have free() do nothing - that's a valid
strategy for embedded systems which might use malloc() for convenience
during initialisation, but do not allocate and free memory during the
application itself.
Once we know what OS the O/P is talking about, and some more information
about the particular usage, it might be possible to help.
I came across an info that claimed that free does not return the
memory to the OS immediately and it returns at the end of the prorcess/
application.
That depends on the OS, and the library used by the application - again, you'll get little useful information until you tell us what OS and tools you are using.
In the internet i found that some Memory Management techniques allow
the immediate return of the freed memory to the OS and others allow
only at the end of the application / process .
Both are perfectly valid techniques, but are appropriate for different sorts of systems. It is the library used by the application that decides which method is used.
So, i started to look for the reasons in the internet . I got some
answers , but
they were not very clear / conclusive, so i posted my query here.
Your posts are not clear either - we don't know what tools you are using, or where you have found this information on the web. We also don't know what you have tried for yourself. Have you looked at the documentation and the source for your application, your library, and your OS?
.
- Follow-Ups:
- Re: free - The Memory is still not returned back to OS
- From: karthikbalaguru
- Re: free - The Memory is still not returned back to OS
- References:
- Re: free - The Memory is still not returned back to OS
- From: badal_akr
- Re: free - The Memory is still not returned back to OS
- From: David Brown
- Re: free - The Memory is still not returned back to OS
- From: karthikbalaguru
- Re: free - The Memory is still not returned back to OS
- Prev by Date: Device programmer
- Next by Date: Re: How can I display my mother tongue (Malayalam) in LCD display?
- Previous by thread: Re: free - The Memory is still not returned back to OS
- Next by thread: Re: free - The Memory is still not returned back to OS
- Index(es):
Relevant Pages
|