|
|
|
|
|
 Re: 还是关于内存泄漏问题 - whone23 [ 2005-05-26 16:05 | 114 byte(s)]
 Re: 还是关于内存泄漏问题 - teawater [ 2005-05-26 14:47 | 112 byte(s)]
 Re: 这样判断内存泄漏是否正确? - sunwen_ling [ 2005-05-26 16:07 | 318 byte(s)]
 Re: 这样判断内存泄漏是否正确? - drangon_zhou [ 2005-05-26 20:31 | 109 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
再次请教:
下面这个程序执行一次,也就是5000次循环调用foo?()函数,执行前后通过free参看内存,发现可用内存减少了1.2M左右,这是否正常?
如果正常的话,减少的1.2M内存为何得不到释放呢?这个应该由内核负责释放的吧。
如果是内存泄漏,那会哪些原因导致的呢?请举点参见错误编码。谢谢!
(我已经用memwatch和valgrind查过,未发现内存泄漏现象)
void main()
{
int t=0;
while(t++<5000){
foo1();
foo2();
}
}
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
(我已经用memwatch和valgrind查过,未发现内存泄漏现象)
cache什么的吧 要是泄露这2个东西还有能查不出的?
|
|
----
读了这么多年的书 还是觉得幼儿园好混
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
以single用户登陆,只运行需要测试的程序。在执行程序前后用free查看used和free Mem, 通过查看used/free 内存值的变化来判断。
如果发现free内存减少,是不是就可以断定内存泄漏了呢?
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
Of course not, I think.
There are various daemon(and other kernel thread) running, the are the potential memory consumer.
The memory leak is strict in the exec session, after the program terminates, the memory used by this program will freed by OS. At this stage, the 'leak' is meaningless.
|
|
|
----
知之为知之,不知为不知,是知也!
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
运行10 000次,前后得free结果分别为:
total used free shared buffers cached
222944 38184 188760 0 4912 8960 //运行前
222944 40744 182200 0 11884 9000 //运行后
free空间减少了6560k,这是什么原因造成的呢?
btw:我是单用户登陆的
|
|
|
[Original]
[Print]
[Top]
|
|
|