<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>转烛空间cache &#187; </title>
	<atom:link href="http://wangliping.net/tag/cache/feed" rel="self" type="application/rss+xml" />
	<link>http://wangliping.net</link>
	<description>记录生活，学习技术</description>
	<lastBuildDate>Fri, 03 Sep 2010 06:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux内存信息查看相关</title>
		<link>http://wangliping.net/linux_mem_info_watch</link>
		<comments>http://wangliping.net/linux_mem_info_watch#comments</comments>
		<pubDate>Wed, 25 Nov 2009 08:13:52 +0000</pubDate>
		<dc:creator>转烛</dc:creator>
				<category><![CDATA[编程技术]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[内存]]></category>

		<guid isPermaLink="false">http://wangliping.net/linux_mem_info_watch</guid>
		<description><![CDATA[free 命令相对于top 提供了更简洁的查看系统内存使用情况： 

　　$ free
　　　total used free shared buffers cachedMem: 

　　　255268 238332 16936 0 85540 126384
　　　-/+ buffers/cache: 26408 228860Swap: 265000 0 265000]]></description>
			<content:encoded><![CDATA[<p>free 命令相对于top 提供了更简洁的查看系统内存使用情况：
<p>　　$ free<br />　　　total used free shared buffers cachedMem:
<p>　　　255268 238332 16936 0 85540 126384<br />　　　-/+ buffers/cache: 26408 228860Swap: 265000 0 265000
<p>　　Mem：表示物理内存统计</p>
<p>　　-/+ buffers/cached：表示物理内存的缓存统计</p>
<p><span id="more-516"></span>
<p>　　Swap：表示硬盘上交换分区的使用情况，这里我们不去关心。 </p>
<p>　　系统的总物理内存：255268Kb（256M），但系统当前真正可用的内存b并不是第一行free 标记的 16936Kb，它仅代表未被分配的内存。
<p>　　我们使用total1、used1、free1、used2、free2 等名称来代表上面统计数据的各值，1、2 分别代表第一行和第二行的数据。
<p>　　total1：表示物理内存总量。
<p>　　used1：表示总计分配给缓存（包含buffers 与cache ）使用的数量，但其中可能部分缓存并未实际使用。
<p>　　free1：未被分配的内存。
<p>　　shared1：共享内存，一般系统不会用到，这里也不讨论。
<p>　　buffers1：系统分配但未被使用的buffers 数量。
<p>　　cached1：系统分配但未被使用的cache 数量。buffer 与cache 的区别见后面。
<p>　　used2：实际使用的buffers 与cache 总量，也是实际使用的内存总量。
<p>　　free2：未被使用的buffers 与cache 和未被分配的内存之和，这就是系统当前实际可用内存。
<p>　　可以整理出如下等式：<br />　　total1 = used1 + free1total1 = used2 + free2used1 = buffers1 + cached1 + used2free2 = buffers1 + cached1 + free1
<p>　　<strong>buffer 与cache 的区别</strong></p>
<blockquote><p>　　A buffer is something that has yet to be “written” to disk. A cache is something that has been “read” from the disk and stored for later use. </p>
</blockquote>
<p>　　更详细的解释参考：Difference Between Buffer and Cache
<p>　　对于共享内存（Shared memory），主要用于在UNIX 环境下不同进程之间共享数据，是进程间通信的一种方法，一般的应用程序不会申请使用共享内存，笔者也没有去验证共享内存对上面等式的影响。如果你有兴趣， 请参考：What is Shared Memory?
<p>　　<strong>Cache</strong>：高速缓存，是位于CPU与主内存间的一种容量较小但速度很高的存储器。由于CPU的速度远高于主内存，CPU直接从内存中存取数据要等待一 定时间周期，Cache中保存着CPU刚用过或循环使用的一部分数据，当CPU再次使用该部分数据时可从Cache中直接调用,这样就减少了CPU的等待 时间,提高了系统的效率。Cache又分为一级Cache(L1 Cache)和二级Cache(L2 Cache)，L1 Cache集成在CPU内部，L2 Cache早期一般是焊在主板上,现在也都集成在CPU内部，常见的容量有256KB或512KB L2 Cache。 </p>
<p>　　<strong>Buffer</strong>：缓冲区，一个用于存储速度不同步的设备或优先级不同的设备之间传输数据的区域。通过缓冲区，可以使进程之间的相互等待变少，从而使从速度慢的设备读入数据时，速度快的设备的操作进程不发生间断。
<p>　　Free中的buffer和cache：（它们都是占用内存）：
<p>　　buffer : 作为buffer cache的内存，是块设备的读写缓冲区
<p>　　cache: 作为page cache的内存, 文件系统的cache
<p>　　参考：<a title="http://zhougaofeng.ixiezi.com/2009/11/25/linux%e4%b8%ad%e5%86%85%e5%ad%98%e4%bf%a1%e6%81%af/" href="http://zhougaofeng.ixiezi.com/2009/11/25/linux%e4%b8%ad%e5%86%85%e5%ad%98%e4%bf%a1%e6%81%af/">http://zhougaofeng.ixiezi.com/2009/11/25/linux%e4%b8%ad%e5%86%85%e5%ad%98%e4%bf%a1%e6%81%af/</a></p>
<h3  class="related_post_title">你可能也感兴趣的文章：</h3><ul class="related_post"><li><a href="http://wangliping.net/how_to_add_swap_method" title="Linux中增加Swap的方法">Linux中增加Swap的方法</a></li><li><a href="http://wangliping.net/how-to-use-fdisk-in-linux" title="实例解说 fdisk 使用方法">实例解说 fdisk 使用方法</a></li><li><a href="http://wangliping.net/c-change-file-permission" title="C语言查看和更改文件的权限">C语言查看和更改文件的权限</a></li><li><a href="http://wangliping.net/source-insight-see-source-code" title="Source-Insight-看大规模大工程源代码">Source-Insight-看大规模大工程源代码</a></li><li><a href="http://wangliping.net/linux-android-x86-test-keyboard-mouse-touch-screen" title="Linux下测试键盘鼠标触摸屏触摸板">Linux下测试键盘鼠标触摸屏触摸板</a></li><li><a href="http://wangliping.net/make_linux_kernel_update" title="编译Linux内核教程（Ubuntu为例）">编译Linux内核教程（Ubuntu为例）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://wangliping.net/linux_mem_info_watch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
