Find the answer to your Linux question:
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, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •