Results 1 to 2 of 2
I am working on the webkit open source code. I see a small function like this
void TCMalloc_SystemRelease(void* start, size_t length)
{
void* newAddress = mmap(start, length, PROT_READ | PROT_WRITE, ...
- 12-21-2010 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 3
mmap question
I am working on the webkit open source code. I see a small function like this
void TCMalloc_SystemRelease(void* start, size_t length)
{
void* newAddress = mmap(start, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
}
This function TCMalloc_SystemRelease() is supposed to release the memory back to the system, but it is calling mmap() function instead of free or delete. My understanding is that mmap is used to allocate the resources. That is it creates a new mapping in the virtual address space of the calling process.
Please can any one let me know is mmap can be used to release the memory back to the system also.
Sorry if I sound stupid
Please help
Thanks in advance
- 12-21-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
mmap() maps a system address to a local process address. The local process can use it, but cannot release it, other than releasing the local virtual address returned by mmap(). Usually one will use munmap() to do that. Anyway, read the manpage for mmap() for more information about these functions.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
