This is contrary to what I have read...since the freed memory return to the OS pool only when the process exits. I maybe wrong but this seems to contradict what I read in this book..
Then what you read is either a pedagogical simplification or an oversight. Since the statement, "free() doesn't return memory to the system", is true for 4.4BSD [see Note 1], and since The Design and Implementation of the 4.4BSD Operating System is the predecessor of The Design and Implementation of the FreeBSD Operating System, perhaps the statement originated in the earlier work and was carried over unintentionally.
The first book was published on May 10, 1996. The second on August, 12, 2004. FreeBSD began returning memory (when possible) to the kernel when it adopted Poul-Henning Kamp's phkmalloc back in September 16, 1995, before either book hit the shelves. From malloc.c revision 1.3:
Freeing an allocation of pages is done by chang-
ing their state in the page directory to MALLOC_FREE,
traversing the free-pages list to find the right place for
this run of pages, collapsing with either or both of the
two neighbouring entries if possible, and if above the
threshold: releasing some pages back to the kernel by
calling brk(2).
In a commit later that year, revision 1.7, December 11, 1995 (still before either book was published), mmap improvements were made to increase the odds of returning memory to the kernel. However, phkmalloc never used mmap to directly satisfy memory allocation requests. Instead, it used mmap to place the page directories (housekeeping data structures) outside the heap. From the commit message:
Quote:
Change phkmalloc so that the page directory is now floating and allocated
via mmap() up around the shared library area. Previously the directory
was allocated from space from it's own memory pool. Because of the way it
was being extended on processes with large malloced data segments (ie: inn)
once the page directory was extended for some reason, it was not possible
to lower the heap size any more to return pages to the OS.
Revision 1.93, January 13, 2006, of malloc.c replaced phkmalloc with jemalloc, whose malloc/free can use mmap/munmap. Among other benefits, this increases the opportunities to return memory to the kernel.
Notes:
1) In the malloc.c cvs history, we see that the initial version of FreeBSD malloc.c came from 4.4BSD Lite. Looking at the code confirms that revision of free() never returns memory to the system.
Last edited by alister; 10-27-2012 at 12:14 AM..
These 3 Users Gave Thanks to alister For This Post:
Hi!! Experts,
Any ideas how to check for the memory leaks in a process during performance testing?? I dont use purify.. Any way of finding it out using default S/W in HP UX-11
Can U gimme pointers to site having good scripts/tutorials on performance testing??
Thanx in Advance..
:) (3 Replies)
Hi folks,
We are using following listed configurations for a particular application.
HP-UX 11i
Sun Java 2 SDK Standard Edition 1.4.1 (version shipped with WebLogic 8)
Oracle 9i Release 2 (Oracle 9.2.0)
BEA WebLogic Server 8.1 SP3
It seems a memory leak when we use above configurations.... (1 Reply)
hi, i am a c++ programmer working on linux(redhat linux8.0) environment, i need to find out the memory leaks, so far i didn't used any tools, so what are the tools are available, and whic one is good to use. plz provide with a small example. (1 Reply)
Hi Unix lovers,
I am facing a strange problem about memory leak. One component of our product show memory leak at customer's end but not in development environment. The memory used by the exe goes on increasing at customer end but not in dev.
customer has same m/c(HP unix 11i) , the same... (1 Reply)
Hi,
Im working on Solaris 9 on SPARC-32 bit running on an Ultra-80, and I have to find out the following:-
1. Total Physical Memory in the system(total RAM).
2. Available Physical Memory(i.e. RAM Usage)
3. Total (Logical) Memory in the system
4. Available (Logical) Memory.
I know... (4 Replies)
Hi all,
I have written a small code just to invoke main and return immediately. When built with libpthread on AIX box, valgrind throws lots of memory leak errors. But when built without libpthread, no issues at all.
Here is the sample run for your look. Any idea where I might be going wrong?... (3 Replies)
Hello!
I've been struggling for not few hours with memory leaks on this
machine. I'm running linux 2.6.32-5-686, and the problem is as follows:
Some months ago, I have compiled kernel 2.6.33-2-686 without any issues
in this same machine. This week I have tried compiling GNUzilla Icecat
and... (23 Replies)
Hi Experts,
Our servers running Solaris 10 with SAP Application. The memory utilization always >90%, but the process on SAP is too less even nothing.
Why memory utilization on solaris always looks high?
I have statement about memory on solaris, is this true:
Memory in solaris is used for... (4 Replies)