Mac OS X的【記憶體】:Wired、Active、Inactive和Free

來源:互聯網
上載者:User

轉自:http://www.19lou.com/forum-1658-thread-25902363-1-1.html

Mac的記憶體使用量: Wired, Active, Inactive和Free

  

   
◇ Wired(聯動): 系統核心佔用的,永遠不會從系統物【[記憶體】中驅除。

   
◇ Active(活躍): 表示這些記憶體資料正在使用種,或者剛被使用過。
    ◇ Inactive(非活躍): 表示這些記憶體中的資料是有效,但是最近沒有被使用。

   
◇ Free(可用空間): 表示這些記憶體中的資料是無效的,即記憶體剩餘量!


當Free的【記憶體】低於某個key值時

    這個key值是由你的實體記憶體大小決定的,系統則會按照以下順序使用Inactive的資源。

   
◇首先,如果Inactive的資料最近被調用了,系統會把它們的狀態改變成Active,並且在原有Active記憶體邏輯地址的後面;

   
◇其次,如果Inactive的記憶體資料最近沒有被使用過,但是曾經被更改過,而還沒有在硬碟的相應虛擬[記憶體]中做修改,系統會對相應硬碟的虛擬記憶體做修改,並把這部分實體記憶體釋放為free供程式使用。

   
◇再次,如果inactive[記憶體]中得資料被在映射到硬碟後再沒有被更改過,則直接釋放成free。

    ◇最後如果active的記憶體一段時間沒有被使用,會被暫時改變狀態為inactive。

  

    所以,如果你的系統裡有少量的free memeory和大量的inactive的memeory,說明你的記憶體是夠用的,系統運行在最佳狀態,只要需要,系統就會使用它們,不用擔心。

    如果系統的free memory和inactive memory都很少,而active memory很多,說明你的[記憶體]不夠了。當然一開機,大部分[記憶體]都是free,這時系統反而不在最佳狀態,因為很多資料都需要從硬碟調用,速度反而慢了。



--------------------------------------------------------------------------------------------------------

以下轉自:http://www.cnblogs.com/tony508/archive/2011/01/28/1946837.html

   相信大家做iPhone開發都遇到過記憶體吃緊的問題,最要命的是不知道究竟自己剛寫的這段代碼用了多少記憶體(被instrument騙過好多次了),下面貼出我常用的查看現有記憶體方法

#import <sys/sysctl.h>#import <mach/mach.h>- (double)availableMemory {    vm_statistics_data_t vmStats;    mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;    kern_return_t kernReturn = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmStats, &infoCount);        if(kernReturn != KERN_SUCCESS) {        return NSNotFound;    }    //vmStats.wire_count    //vmStats.inactive_count    //vmStats.active_count    return ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;}
官方的名詞解釋 

Free memory

This is RAM that's not being used.

 

Wired memory

Information in this memory can't be moved to the hard disk, so it must stay in RAM. The amount of Wired memory depends on the applications you are using.

 

Active memory

This information is currently in memory, and has been recently used.

 

Inactive memory

This information in memory is not actively being used, but was recently used.

For example, if you've been using Mail and then quit it, the RAM that Mail was using is marked as Inactive memory. This Inactive memory is available for use by another application, just like Free memory.  However, if you open Mail before its Inactive memory
is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading Mail from the slower hard disk.

 

Used

This is the total amount of memory used.

 

VM size

This is the total amount of Virtual Memory for all processes on your Mac. 

 

Page ins / Page outs

This refers to the amount of information moved between RAM and the hard disk. This number is a cumulative amount of data that Mac OS X has moved between RAM and disk space.

Tip: Page outs occur when your Mac has to write information from RAM to the hard drive (because RAM is full).  Adding more RAM may reduce page outs.

 

Swap used

This is the amount of information copied to the swap file on your hard drive.

(更多記憶體使用量資訊可查閱蘋果開發文檔:Memory Usage Performance Guidelines )

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.