﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-woooha</title><link>http://www.cppblog.com/woooha/</link><description /><language>zh-cn</language><lastBuildDate>Mon, 06 Apr 2026 00:11:25 GMT</lastBuildDate><pubDate>Mon, 06 Apr 2026 00:11:25 GMT</pubDate><ttl>60</ttl><item><title>Mesa安装手记--在Ubuntu 9.10</title><link>http://www.cppblog.com/woooha/archive/2010/03/08/109156.html</link><dc:creator>杨帆</dc:creator><author>杨帆</author><pubDate>Sun, 07 Mar 2010 16:36:00 GMT</pubDate><guid>http://www.cppblog.com/woooha/archive/2010/03/08/109156.html</guid><wfw:comment>http://www.cppblog.com/woooha/comments/109156.html</wfw:comment><comments>http://www.cppblog.com/woooha/archive/2010/03/08/109156.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/woooha/comments/commentRss/109156.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woooha/services/trackbacks/109156.html</trackback:ping><description><![CDATA[<meta http-equiv="CONTENT-TYPE" content="text/html; charset="utf-8"">
<title></title>
<meta name="GENERATOR" content="OpenOffice.org 3.1  (Linux)">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</style>
<p style="margin-bottom: 0cm; text-align: left;"><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>学计算机图形学用到<font face="AR PL UMing CN, serif">OpenGL</font>，不过想在<font face="AR PL UMing CN, serif">Ubuntu</font>下进行实现，查查了查，<font face="AR PL UMing CN, serif">OpenGL
</font>在<font face="AR PL UMing CN, serif">linux</font>下的<font face="AR PL UMing CN, serif">C</font>绑定是<font face="AR PL UMing CN, serif">Mesa</font>，可是安装这玩意儿可是费了我一番功夫。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>首先，从<font face="AR PL UMing CN, serif">www.Mesa3D.org</font>下载了三个文件，<font face="AR PL UMing CN, serif">MesaDemos-X.Y.Z.tar.gz
,
MesaGLUT-X.Y.Z.tar.gz,MesaLib-X.Y.Z.tar.gz,</font>分别是<font face="AR PL UMing CN, serif">Demo</font>，<font face="AR PL UMing CN, serif">GLUT</font>库和最主要的<font face="AR PL UMing CN, serif">Mesa</font>（<font face="AR PL UMing CN, serif">OpenGL</font>）链接文件。这里<font face="AR PL UMing CN, serif">X.Y.Z</font>是<font face="AR PL UMing CN, serif">Mesa</font>的版本，我下载的是<font face="AR PL UMing CN, serif">7.6.1</font>。解压后的得到一个文件夹<font face="AR PL UMing CN, serif">Mesa-X.Y.Z</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>在<font face="AR PL UMing CN, serif">bash</font>中进入这个文件夹中，执行<font face="AR PL UMing CN, serif">./configure</font>进行配置，额，少了一些库。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>首先是<font face="AR PL UMing CN, serif">libdrm</font>，在软件包管理器中，找到了<font face="AR PL UMing CN, serif">libdrm-dev</font>，安装后，再次执行<font face="AR PL UMing CN, serif">./configure</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>还是少库。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>少了<font face="AR PL UMing CN, serif">dri2proto</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>查了查，找到了<font face="AR PL UMing CN, serif">x11proto-dri2-dev,</font>安装后执行<font face="AR PL UMing CN, serif">./configure</font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>少库。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>少了<font face="AR PL UMing CN, serif">xxf86vm</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>在软件包中找到<font face="AR PL UMing CN, serif">libxxf86vm-dev</font>安装后，额，不抱希望了，执行<font face="AR PL UMing CN, serif">./configure</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font><font face="AR PL UMing CN, serif">&#8230;&#8230;&#8230;&#8230;</font>少库。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>这次是<font face="AR PL UMing CN, serif">xt</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>找了找，在软件包中找到了<font face="AR PL UMing CN, serif">libxt-dev</font>，安装后。<font face="AR PL UMing CN, serif">./configure</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>成功了！提示我<font face="AR PL UMing CN, serif">make</font>。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>哈哈，真高兴！可是<font face="AR PL UMing CN, serif">make</font>就出问题了<font face="AR PL UMing CN, serif">,</font>提示我少了<font face="AR PL UMing CN, serif">fdepend</font>这个东西。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>可是我怎么都找不到这个东西在哪里。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>很郁闷。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>继续上<font face="AR PL UMing CN, serif">www.Mesa3D.org</font>看看官方的说明，上面说安装<font face="AR PL UMing CN, serif">Mesa</font>需要４个东西。</p>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset="utf-8"">
<title></title>
<meta name="GENERATOR" content="OpenOffice.org 3.1  (Linux)">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</style>
<ol>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif"><a  href="http://xorg.freedesktop.org/releases/individual/proto/">dri2proto</a>
    version 1.99.3 or later </font>
    </p>
    </li>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">Linux
    2.6.28 </font>
    </p>
    </li>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif"><a  href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a>
    version 2.4.3 or later </font>
    </p>
    </li>
    <li>
    <p align="LEFT"><font face="AR PL UMing CN, serif">Xorg server
    version 1.5 or later </font>
    </p>
    </li>
</ol>
<font face="AR PL UMing CN, serif"> </font>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>前三个，我都有安阿？第四个是什么东西，继续在软件包管理器中捣鼓。找到了<font face="AR PL UMing CN, serif">xorg-dev</font>这个安装。再次<font face="AR PL UMing CN, serif">make,</font>竟然成功了！好吧，<font face="AR PL UMing CN, serif">make
install</font>，也成功了。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>然后接下来，验证<font face="AR PL UMing CN, serif">Mesa</font>能不能用。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>转到<font face="AR PL UMing CN, serif">Mesa-X.Y.Z/progs/demos</font>目录下，执行<font face="AR PL UMing CN, serif">./gears</font>，提示找不到<font face="AR PL UMing CN, serif">libglut.so.3(</font>好像是这个，记不大清了<font face="AR PL UMing CN, serif">)</font>，看看<font face="AR PL UMing CN, serif">Mesa3D</font>上让执行这么几个命令。</p>
<ol>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif"><strong>cd
    lib/	</strong> </font>（转到了<font face="AR PL UMing CN, serif">Mesa-X.Y.Z/lib/</font>目录下<font face="AR PL UMing CN, serif">)</font></p>
    </li>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif"><strong>export
    LD_LIBRARY_PATH=${PWD}</strong> </font>
    </p>
    </li>
    <li>
    <p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif"><strong>export
    LIBGL_DRIVERS_PATH=${PWD}</strong> (if using DRI drivers) </font>
    </p>
    </li>
</ol>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>现在再执行<font face="AR PL UMing CN, serif">Mesa-X.Y.Z/progs/demos/gears</font>可以运行了，看到了齿轮在转动！</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>可是在<font face="AR PL UMing CN, serif">Mesa-X.Y.Z/progs/samples/</font>编译一个文件</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp; &nbsp;		</font><font face="AR PL UMing CN, serif">gcc `pkg-config opengl --cflags --libs ` point.c -o point
</font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>出现了好多错误。</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>额，怎么回事？</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>才知道，编译文件是找不到<font face="AR PL UMing CN, serif">glut</font>库，仔细一看才发现，自己编译文件用的命令错了，应该是</p>
<p style="margin-bottom: 0cm; text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>&nbsp; <font face="AR PL UMing CN, serif">gcc
`pkg-config <font color="#ff0000"><strong><span style="background: #ffffff none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;">glut</span></strong></font>
--cflags --libs ` point.c -o point</font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font face="AR PL UMing CN, serif">		</font><font face="AR PL UMing CN, serif">&nbsp;&nbsp;&nbsp;		</font>好了，现在一切没有问题了，安装成功！</p>
<p style="margin-bottom: 0cm;" align="LEFT"><br>
</p><img src ="http://www.cppblog.com/woooha/aggbug/109156.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woooha/" target="_blank">杨帆</a> 2010-03-08 00:36 <a href="http://www.cppblog.com/woooha/archive/2010/03/08/109156.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在不同系统下分配大内存的测试（c.c.l.c上一人的帖子，在老家网吧不方便实验，记下啦，试试）</title><link>http://www.cppblog.com/woooha/archive/2010/02/18/108034.html</link><dc:creator>杨帆</dc:creator><author>杨帆</author><pubDate>Thu, 18 Feb 2010 12:01:00 GMT</pubDate><guid>http://www.cppblog.com/woooha/archive/2010/02/18/108034.html</guid><wfw:comment>http://www.cppblog.com/woooha/comments/108034.html</wfw:comment><comments>http://www.cppblog.com/woooha/archive/2010/02/18/108034.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/woooha/comments/commentRss/108034.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/woooha/services/trackbacks/108034.html</trackback:ping><description><![CDATA[今天在solaris下做这个测试
<br>
<br>测试代码如下：
<br>#include &lt;stdlib.h&gt;
<br>#include &lt;unistd.h&gt;
<br>int main(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void* p=malloc(512*1024*1024);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(p==NULL) return -1;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(10000000);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;
<br>
<br>}
<br>
<br>
<br>然后我用g++ 4.3.2编译
<br>g++-4.3.2 -o testm testm.c
<br>
<br>开了5个，开到第6个的时候，malloc就返回-1了。可是，可是，令人惊奇的是
<br>这个时候，我无论是用vmstat还是用mdb看，我都还有大量的空闲的物理内存
<br>&gt;::memstat
<br>Page Summary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MB&nbsp; %Tot
<br>------------&nbsp;&nbsp;&nbsp;&nbsp; ----------------&nbsp; ----------------&nbsp; ----
<br>Kernel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 144849&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 565&nbsp;&nbsp; 14%
<br>ZFS File Data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 62043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 242&nbsp;&nbsp;&nbsp; 6%
<br>Anon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 146323&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 571&nbsp;&nbsp; 14%
<br>Exec and libs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3640&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 14&nbsp;&nbsp;&nbsp; 0%
<br>Page cache&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 34357&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 134&nbsp;&nbsp;&nbsp; 3%
<br>Free (cachelist)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 35896&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 140&nbsp;&nbsp;&nbsp; 3%
<br>Free (freelist)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 600734&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2346&nbsp;&nbsp; 58%
<br>
<br>Total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027842&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4015
<br>Physical&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027841&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4015
<br>这与我开这几个程序之前，没有明显的变化。（相比而下，在windows下，这个时
候系统已经卡的快嗝屁了）
<br>
<br>然后我用ps来看
<br># ps -eo pid,vsz,rss,args |grep testm
<br>&nbsp;1298 527292 1356 ./testm
<br>&nbsp;1309 4224 1256 grep testm
<br>&nbsp;1300 527292 1356 ./testm
<br>&nbsp;1302 527292 1356 ./testm
<br>&nbsp;1296 527292 1356 ./testm
<br>&nbsp;1304 527292 1356 ./testm
<br>
<br># pmap 1296
<br>1296:&nbsp;&nbsp;&nbsp; ./testm
<br>08046000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8K rwx--&nbsp;&nbsp;&nbsp; [ stack ]
<br>08050000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K r-x--&nbsp; /tmp/testm
<br>08060000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8K rwx--&nbsp; /tmp/testm
<br>08062000&nbsp; 524296K rwx--&nbsp;&nbsp;&nbsp; [ heap ]
<br>FEB70000&nbsp;&nbsp;&nbsp;&nbsp; 320K r-x--&nbsp; /lib/libm.so.2
<br>FEBCF000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8K rwx--&nbsp; /lib/libm.so.2
<br>FECD0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24K rwx--&nbsp;&nbsp;&nbsp; [ anon ]
<br>FECE0000&nbsp;&nbsp;&nbsp; 1280K r-x--&nbsp; /usr/lib/libc/libc_hwcap1.so.1
<br>FEE20000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 28K rwx--&nbsp; /usr/lib/libc/libc_hwcap1.so.1
<br>FEE27000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8K rwx--&nbsp; /usr/lib/libc/libc_hwcap1.so.1
<br>FEE30000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 52K r-x--&nbsp; /usr/lib/libgcc_s.so.1
<br>FEE4C000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rwx--&nbsp; /usr/lib/libgcc_s.so.1
<br>FEE50000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rwx--&nbsp;&nbsp;&nbsp; [ anon ]
<br>FEE60000&nbsp;&nbsp;&nbsp;&nbsp; 856K r-x--&nbsp; /usr/lib/libstdc++.so.6.0.10
<br>FEF45000&nbsp;&nbsp;&nbsp;&nbsp; 160K rwx--&nbsp; /usr/lib/libstdc++.so.6.0.10
<br>FEF6D000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24K rwx--&nbsp; /usr/lib/libstdc++.so.6.0.10
<br>FEF80000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K r--s-&nbsp; /var/ld/ld.config
<br>FEF90000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rwx--&nbsp;&nbsp;&nbsp; [ anon ]
<br>FEFA0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rw---&nbsp;&nbsp;&nbsp; [ anon ]
<br>FEFB0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rw---&nbsp;&nbsp;&nbsp; [ anon ]
<br>FEFBE000&nbsp;&nbsp;&nbsp;&nbsp; 180K r-x--&nbsp; /lib/ld.so.1
<br>FEFFB000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8K rwx--&nbsp; /lib/ld.so.1
<br>FEFFD000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4K rwx--&nbsp; /lib/ld.so.1
<br>&nbsp;total&nbsp;&nbsp;&nbsp; 527292K
<br>
<br>
<br>系统的确给这个进程分配了地址空间（看它的heap有多大），但是压根儿就没有给
它分配物理内存。我想不出的是，它依据什么来拒绝新的申请。
<br>由于环境有限，我没有找到良好的环境在freebsd下重复这个实验。我在
freebsd.unix-center.net上做这个测试，但是把每个进程分配的内存缩小到64M,
然后开了100个这样的进程，据估计至少需要6G的内存，malloc一直都是成功的，
我的手酸了，懒得弄了。
<br>
<br>
<br>最有趣的在于这个：
<br>#include &lt;stdlib.h&gt;
<br>#include &lt;unistd.h&gt;
<br>#include &lt;string.h&gt;
<br>
<br>int main(){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void* p=malloc(512*1024*1024);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(p==NULL) return -1;
<br>&nbsp;&nbsp;&nbsp;&nbsp;memset(p,0,512*1024*1024);
<br>&nbsp;&nbsp;&nbsp;&nbsp;free(p);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(10000000);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;
<br>
<br>}
<br>
<br>用ps/pmap去看，事实证明，free函数根本就没有释放物理内存。free是把malloc
得到的物理内存还给了自己进程，而不是还给了操作系统。
<br>在这一点上，freebsd是有差别的。执行完free之后，rss明显降了下来
<br>
<br>
<br>
<br><img src ="http://www.cppblog.com/woooha/aggbug/108034.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/woooha/" target="_blank">杨帆</a> 2010-02-18 20:01 <a href="http://www.cppblog.com/woooha/archive/2010/02/18/108034.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>