There are two instances where we make virtual copies of memory allocated via FastMalloc. One is when we use vm_copy in PurgeableBuffer::create() and the other is implicit in CoreIPC where we use the MACH_MSG_VIRTUAL_COPY flag in Connection::sendOutgoingMessage. In both cases, the kernel creates a second reference to the region being copied. These additional references preclude using the MADV_FREE_REUSABLE flag in madvise. This stops us from making memory available to the system for other processes.
Created attachment 102602 [details] Proposed patch
Two defects in Radar: <rdar://problem/9747241> and <rdar://problem/9747279>.
Comment on attachment 102602 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=102602&action=review > Source/WebCore/platform/mac/PurgeableBufferMac.cpp:67 > + memcpy(reinterpret_cast<char*>(buffer), data, size); Since memcpy’s destination is a void* I would not expect you’d need to typecast a pointer to use it as a memcpy destination. Can you just pass buffer without a typecast?
(In reply to comment #3) > (From update of attachment 102602 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=102602&action=review > > > Source/WebCore/platform/mac/PurgeableBufferMac.cpp:67 > > + memcpy(reinterpret_cast<char*>(buffer), data, size); > > Since memcpy’s destination is a void* I would not expect you’d need to typecast a pointer to use it as a memcpy destination. Can you just pass buffer without a typecast? The cast is needed because vm_address_t is really a uintptr_t which is an unsigned long, a non-pointer type.
Committed r92231: <http://trac.webkit.org/changeset/92231>