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
Thanks in advance
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.