免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1413 | 回复: 0
打印 上一主题 下一主题

[linux 2.6.22 kernel] execl 内存泄露跟踪 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-10 10:25 |只看该作者 |倒序浏览

                遇到了嵌入式linux下面系统级内存泄露问题。跟踪问题日志。
平台:ARM9
内核:2.6.22
问题:execl造成系统内存减少,通过cat /proc/memoinfo 发现少的内存并且都移往slab中去了
测试代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
    int i = 0;
    int pid = 0;
    for (i=0; i<1000; i++)
    {
        pid = fork();
        if (pid < 0)
        {
            printf("fork() fail!\n");
            continue;
        }
        else if (pid == 0) //child
        {
            //system("ls");
            execl("/bin/ls", "ls", "", NULL);
            printf("execl() here!\n");
            exit(0);
        }
        else
        {
            waitpid(pid, 0, 0);
            printf("[%d] exited!", pid);
        }
        printf("%d\n", i);
        
    }
    return 0;
}
20091010:在PC上ubuntu 9.04上测试这个程序发现没有内存减少的现象。在ARM9上发现,每次执行1000次左右,导致有300k左右的内存减少。可能与内核版本(ubuntu 9.04是2.6.30的kernel版本)有关系,通过google或百度并没有发现有这样的问题。估计是配置内核导致的问题。下一步将通过cat /proc/slabinfo 来研究内存多出来的部分的来源。
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103718/showart_2066890.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP