Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| memory [2013/02/20 13:20] – s/Move/Moved KubilayKocak | memory [2018/09/06 01:59] (current) – MarkJohnston | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | A plain language description of the memory stats seen in places like top(8) and sysctl output, designed specifically for a non-developer audience. | + | A plain language description of the memory stats seen in places like top(1) and sysctl output, designed specifically for a non-developer audience. |
| - | ===== General | + | ===== Overview |
| - | Userland | + | %%FreeBSD%%' |
| - | ===== Memory Classes ===== | + | %%FreeBSD%% uses a set of 3 queues to manage pageable memory. |
| - | **Active** Queue | + | Pageable memory consists of anonymous memory and file data. Anonymous memory has no dedicated backing storage, and will be written |
| - | * " | + | |
| - | * Moved to Inactive when act(ivity)_count=0 (by pagedaemon) | + | |
| - | * act_count | + | |
| - | * " | + | |
| - | **Inactive** Queue | + | |
| - | * Inactively | + | * the contents of a MD device of type " |
| - | * Not recently used (LRU) | + | * tmpfs filesystems |
| - | * Cannot be re-allocated to other processes | + | * %%SysV%% or POSIX shared memory segments |
| - | **Cached** | + | File data is simply the cached contents of files, and file metadata. |
| - | * Almost | + | |
| - | * Backed by swap or files (ie mmap(%%))%% | + | |
| - | * Available | + | |
| - | **Free** | + | Pages belonging to page queues are in one of two states: clean or dirty. |
| - | * Literally Free. | + | |
| - | **Wired** | + | ===== Memory Classes ===== |
| - | * Locked in-memory (by kernel, mlock, etc) | + | |
| - | * Cannot be swapped out | + | |
| - | * Kernel, kernel modules and kernel heap live here | + | |
| - | ===== Other ===== | + | **Active** |
| + | * Contains pages " | ||
| + | * Contains a mix of clean and dirty pages | ||
| + | * Pages are regularly scanned by the page daemon (each page is visited once every vm.pageout_update_period seconds) | ||
| + | * Scans check to see if the page has been referenced since the last scan | ||
| + | * If enough scans complete without seeing a reference, the page is moved to the inactive queue | ||
| + | * Implements pseudo-LRU | ||
| - | **Buffer** | + | **Inactive** |
| - | * Accounts for Disk IO cache entries for non ZFS filesystems | + | * Contains pages aged out of the active queue |
| - | * Data may be stored in Active, Inactive | + | * Contains pages evicted from the buffer |
| - | * Only usable | + | * Contains a mix of clean and dirty pages |
| + | * Pages are scanned | ||
| + | * Pages which have been referenced are moved back to the active queue or the tail of the inactive queue | ||
| + | * Pages which are dirty are moved to the tail of the laundry queue | ||
| + | * Unreferenced, | ||
| + | * Implements second-chance LRU | ||
| - | ===== Thanks ===== | + | **Laundry** |
| + | * Queue for managing dirty inactive pages, which must be cleaned (" | ||
| + | * Managed by a separate thread, the laundry thread, instead of the page daemon | ||
| + | * Laundry thread launders a small number of pages to balance the inactive and laundry queues | ||
| + | * Frequency of laundering depends on: | ||
| + | * How many clean pages the page daemon is freeing; more frees contributes to a higher frequency of laundering | ||
| + | * The size of the laundry queue relative to the inactive queue; if the laundry queue is growing, we will launder more frequently | ||
| + | * Pages are scanned by the laundry thread (starting from the head of the queue): | ||
| + | * Pages which have been referenced are moved back to the active queue or the tail of the laundry queue | ||
| + | * Dirty pages are laundered and then moved close to the head of the inactive queue | ||
| - | Special thanks to **avg** and **zont** for putting up with my probing questions for over and hour to squeeze this valuable information out :) | + | **Free** |
| + | | ||
| + | |||
| + | **Wired** | ||
| + | * Non-pageable memory: cannot be freed until explicitly released by the owner | ||
| + | * Userland memory can be wired by mlock(2) (subject to system and per-user limits) | ||
| + | * Kernel memory allocators return wired memory | ||
| + | * Contents of the ARC and the buffer cache are wired | ||
| + | * Some memory is permanently wired and is never freed (e.g., the kernel file itself) | ||