诶。。你真的不明白么。。(好吧 黑这个词我用错了,但是请你说之前多查查资料)
http://imgup-domain1.stor.sinaapp.com/upload/1403799507.png请看清楚 Available和Free,以及Use还有Standby。
Available 意为可获取的,包括cache,那么windows的cache到底是什么用的呢
Standby: Pages of physical ram not actively being used. These are still left in physical ram but will be repurposed first by the memory manager (either returned to the active list or zeroed out and reused) if something needs physical ram for active pages. Standby pages are essentially cache – it’s better to have infrequently used data kept in RAM “just in case” than pushing it out to disk when the memory isn’t needed for anything else.
Modified: Similar to Standby, but these are pages of physical RAM that have been changed and must be flushed to disk before reusing them.
gc是需要时间的,所以说系统一般会预留一定的内存作为Free区域,防止有进程突发请求内存,从而导致的gc时间内的卡顿。
关于这部分,你还可以看看Windows 的Pages和Cache的关系。以及Chrome切换的时候,大部分是卡在硬盘上,因为你很久不看的东西,系统 认为是长期不用的,全部塞到Pages文件,也就是所谓的虚拟内存出来了。这时候虽然cpu看起来很低,但是很大多部分Cpu都在等待io上了。如果你有Linux使用经验应该很好理解,top中的wait%就是专门来表达这个的。
所以会出现 cpu占用低,但是很卡 硬盘灯狂闪的情况
另外看看Linux一贯的做法吧
http://imgup-domain1.stor.sinaapp.com/upload/1403799881.pnghttp://imgup-domain1.stor.sinaapp.com/upload/1403799896.png所以在内存足够的情况下,系统一定会预留一部分Free内存的。防止gc期间导致的卡顿。
关于Linux中的cache我也顺便贴出来吧,red hat官方的解释
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Tuning_and_Optimizing_Red_Hat_Enterprise_Linux_for_Oracle_9i_and_10g_Databases/chap-Oracle_9i_and_10g_Tuning_Guide-Memory_Usage_and_Page_Cache.htmlIn this example the total amount of available memory is 4040360 KB. 264224 KB are used by processes and 3776136 KB are free for other applications. Do not get confused by the first line which shows that 28160KB are free! If you look at the usage figures you can see that most of the memory use is for buffers and cache. Linux always tries to use RAM to speed up disk operations by using available memory for buffers (file system metadata) and cache (pages with actual contents of files or block devices). This helps the system to run faster because disk information is already in memory which saves I/O operations. If space is needed by programs or applications like Oracle, then Linux will free up the buffers and cache to yield memory for the applications. If your system runs for a while you will usually see a small number under the field "free" on the first line.