> On Jul 4, 2016, at 8:12 PM, Steve Sisak <[email protected]> wrote:
> 
> I think there may be more information in the guidelines, but don’t have time 
> to re-read the full document at the moment.
> 


Found it:

https://developer.apple.com/library/prerelease/content/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html#//apple_ref/doc/uid/20001881-99765
Allocating Large Memory Blocks using Malloc
For large memory allocations, where large is anything more than a few virtual 
memory pages, malloc automatically uses the vm_allocateroutine to obtain the 
requested memory. The vm_allocate routine assigns an address range to the new 
block in the logical address space of the current process, but it does not 
assign any physical memory to those pages right away. Instead, the kernel does 
the following:
 <>It maps a range of memory in the virtual address space of this process by 
creating a map entry; the map entry is a simple structure that defines the 
starting and ending addresses of the region.
The range of memory is backed by the default pager. 
The kernel creates and initializes a VM object, associating it with the map 
entry.
At this point there are no pages resident in physical memory and no pages in 
the backing store. Everything is mapped virtually within the system. When your 
code accesses part of the memory block, by reading or writing to a specific 
address in it, a fault occurs because that address has not been mapped to 
physical memory. In OS X, the kernel also recognizes that the VM object has no 
backing store for the page on which this address occurs. The kernel then 
performs the following steps for each page fault: <>
It acquires a page from the free list and fills it with zeroes.
It inserts a reference to this page in the VM object’s list of resident pages.
 <> <>It maps the virtual page to the physical page by filling in a data 
structure called the pmap. The pmap contains the page table used by the 
processor (or by a separate memory management unit) to map a given virtual 
address to the actual hardware address.
The granularity <> of large memory blocks is equal to the size of a virtual 
memory page, or 4096 bytes. In other words, any large memory allocations that 
are not a multiple of 4096 are rounded up to this multiple automatically. Thus, 
if you are allocating large memory buffers, you should make your buffer a 
multiple of this size to avoid wasting memory. 
 <>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to