Wired Memory
https://developer.apple.com/library/content/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html#//apple_ref/doc/uid/20001880-99714-TPXREF106
Wired memory (also called resident memory) stores kernel code and data structures that must never be paged out to disk. Applications, frameworks, and other user-level software cannot allocate wired memory. However, they can affect how much wired memory exists at any time. For example, an application that creates threads and ports implicitly allocates wired memory for the required kernel resources that are associated with them.
Table 2 lists some of the wired-memory costs for application-generated entities.
Resource |
Wired Memory Used by Kernel |
---|---|
Process |
16 kilobytes |
Thread |
blocked in a continuation—5 kilobytes; blocked—21 kilobytes |
Mach port |
116 bytes |
Mapping |
32 bytes |
Library |
2 kilobytes plus 200 bytes for each task that uses it |
Memory region |
160 bytes |
Note: These measurements may change with each new release of the operating system. They are provided here to give you a rough estimate of the relative cost of system resource usage.
As you can see, every thread, process, and library contributes to the resident footprint of the system. In addition to your application using wired memory, however, the kernel itself requires wired memory for the following entities:
VM objects
the virtual memory buffer cache
I/O buffer caches
drivers
Wired data structures are also associated with the physical page and map tables used to store virtual-memory mapping information, Both of these entities scale with the amount of available physical memory. Consequently, when you add memory to a system, the amount of wired memory increases even if nothing else changes. When a computer is first booted into the Finder, with no other applications running, wired memory can consume approximately 14 megabytes of a 64 megabyte system and 17 megabytes of a 128 megabyte system.
Wired memory pages are not immediately moved back to the free list when they become invalid. Instead they are “garbage collected” when the free-page count falls below the threshold that triggers page out events.
Page Lists in the Kernel
The kernel maintains and queries three system-wide lists of physical memory pages:
The active list contains pages that are currently mapped into memory and have been recently accessed.
The inactive list contains pages that are currently resident in physical memory but have not been accessed recently. These pages contain valid data but may be removed from memory at any time.
The free list contains pages of physical memory that are not associated with any address space of VM object. These pages are available for immediate use by any process that needs them.
When the number of pages on the free list falls below a threshold (determined by the size of physical memory), the pager attempts to balance the queues. It does this by pulling pages from the inactive list. If a page has been accessed recently, it is reactivated and placed on the end of the active list. In OS X, if an inactive page contains data that has not been written to the backing store recently, its contents must be paged out to disk before it can be placed on the free list. (In iOS, modified but inactive pages must remain in memory and be cleaned up by the application that owns them.) If an inactive page has not been modified and is not permanently resident (wired), it is stolen (any current virtual mappings to it are destroyed) and added to the free list. Once the free list size exceeds the target threshold, the pager rests.
The kernel moves pages from the active list to the inactive list if they are not accessed; it moves pages from the inactive list to the active list on a soft fault (see Paging In Process). When virtual pages are swapped out, the associated physical pages are placed in the free list. Also, when processes explicitly free memory, the kernel moves the affected pages to the free list.
Paging Out Process
In OS X, when the number of pages in the free list dips below a computed threshold, the kernel reclaims physical pages for the free list by swapping inactive pages out of memory. To do this, the kernel iterates all resident pages in the active and inactive lists, performing the following steps:
If a page in the active list is not recently touched, it is moved to the inactive list.
If a page in the inactive list is not recently touched, the kernel finds the page’s VM object.
If the VM object has never been paged before, the kernel calls an initialization routine that creates and assigns a default pager object.
The VM object’s default pager attempts to write the page out to the backing store.
If the pager succeeds, the kernel frees the physical memory occupied by the page and moves the page from the inactive to the free list.
Note: In iOS, the kernel does not write pages out to a backing store. When the amount of free memory dips below the computed threshold, the kernel flushes pages that are inactive and unmodified and may also ask the running application to free up memory directly. For more information on responding to these notifications, see Responding to Low-Memory Warnings in iOS.
Wired Memory的更多相关文章
- iOS多线程编程指南(二)线程管理
当应用程序生成一个新的线程的时候,该线程变成应用程序进程空间内的一个实体.每个线程都拥有它自己的执行堆栈,由内核调度独立的运行时间片.一个线程可以和其他线程或其他进程通信,执行I/O操作,甚至执行任何 ...
- mac下python实现vmstat
mac下没有linux/unix 的vmstat,只有vm_stat; sh-3.2# vm_statMach Virtual Memory Statistics: (page size of 409 ...
- Thread Costs
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/CreatingTh ...
- iOS 获取APP的CPU、内存等信息
目标是开发一个SDK,嵌入到APP里面,用来统计当前APP的实时CPU.内存等信息 2015.11.17 http://stackoverflow.com/questions/12889422/ios ...
- vmstat命令详解--转载
一.前言 vmstat命令: 用来获得有关进程.虚存.页面交换空间及 CPU活动的信息.这些信息反映了系统的负载情况 二.虚拟内存运行原理 在系统中运行的每个进程都需要使用到内存,但不是每个进程都需 ...
- Linux命令详解——vmstat
Vmstat命令详解 一.前言 vmstat命令: 用来获得有关进程.虚存.页面交换空间及 CPU活动的信息.这些信息反映了系统的负载情况 二.虚拟内存运行原理 在系统中运行的每个进程都需要使用到内 ...
- 【NX二次开发】NX内部函数,libugui.dll文件中的内部函数
本文分为两部分:"带参数的函数"和 "带修饰的函数". 浏览这篇博客前请先阅读: [NX二次开发]NX内部函数,查找内部函数的方法 带参数的函数: bool A ...
- PatentTips - Reducing Write Amplification in a Flash Memory
BACKGROUND OF THE INVENTION Conventional NAND Flash memories move data in the background to write ov ...
- Java 堆内存与栈内存异同(Java Heap Memory vs Stack Memory Difference)
--reference Java Heap Memory vs Stack Memory Difference 在数据结构中,堆和栈可以说是两种最基础的数据结构,而Java中的栈内存空间和堆内存空间有 ...
随机推荐
- 使用imp命令和exp命令对oracle数据库进行导入导出操作
命令说明 imp命令和exp命令需要在cmd命令窗口下执行,并且需要在系统环境变量中配置imp,exp命令所在目录 导出命令 --全库导出 exp system/systempassword@orcl ...
- Spark Streaming 官网上提到的几点调优
总的来说,需要考虑以下两点: 1. 有效地运用集群资源去减少每个批次处理的时间 2. 正确的设置batch size,以使得处理速度能跟上接收速度 一. 为了减少处理时间,主要有以下几个优化点: 1 ...
- cf837D(01背包)
题目链接: http://codeforces.com/contest/837/problem/D 题意: 给出 n 个数, 从中选出 k 个数使得这 k 个数的乘积末尾 0 最多 . 思路: 先记录 ...
- JavaScript for impatient programmers
参考 作者发布的在线HTML版本(包含大部分主要章节,只缺少四个额外章节)——https://exploringjs.com/impatient-js/toc.html 作者的博客——http://2 ...
- ios 容错处理AvoidCrash
程序因为很多原因容易出现崩溃问题,比如数组越界.空字符串等造成的崩溃 // 在AppDelegate 写如下代码 初始化防止程序因数组和字符串等崩溃问题 //初始化 AvoidCrash (常用对象防 ...
- Anniversary party (树形DP)
There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The Un ...
- 示例1-苏宁每日自动登录打卡-结合Au3
public class SuningAutoClock { public static void AutoClock() throws IOException, InterruptedExcepti ...
- X64下IIS调用32位的dll
WebAPI项目中遇到了需要调用32位C++的dll的情况,调试的时候能正常调用,但是发布了之后部署在IIS中出现了BadFormatImage异常, 解决方法是在IIS中相应应用程序池=>高级 ...
- 使用Foxfly.Net读取STEP文件
Foxfly.Net是具备基本的几何建模和CAD文件读取功能.本文主要介绍读取STP/STEP文件的使用方法. 1.初始化 项目中引入FoxflyNet.dll程序集,在Program.cs中初始化建 ...
- spring batch 读取多个文件数据导入数据库
项目的目录结构 需要读取文件的的数据格式 applicatonContext.xml的配置 <?xml version="1.0" encoding="UTF-8& ...