So far the best reference I've found is
PurgeableBufferMac.cpp in the WebKit sources. It shows how to use the calls, but is rather sparse on comments.
Some questions I have are:
• Do I have to initially vm_allocate a block as purgeable in order to later mark it for purging via vm_purgable_control? Or is it possible to take a regular vm_allocated block and make it purgeable later on?
• If that's not possible, would it make sense to use VM_FLAGS_PURGABLE when allocating any block I might possibly want to purge later on? (I.e. for all block sizes >32k, call vm_allocate with the purgeable flag rather than malloc.) Or would it be bad for system performance to have too many potentially-purgeable (but not marked as volatile) blocks around?
• Is there a way to inspect a running process and determine how much of its address space is purgeable and/or volatile? The vmmap tool doesn't seem to show these attributes when listing vm_allocate'd regions. And presumably volatile space is still counted in RSIZE.
• For testing purposes, is there a way to trigger purging of volatile regions? I'd like to wire up a button or hot-key that could be used to do this, so I could make sure the app doesn't crash and that its RSIZE goes down.
Thanks!
—Jens