zoukankan      html  css  js  c++  java
  • DTrace memory leak 内存泄露

     

    http://blog.sina.com.cn/s/blog_538040b70100eecn.html
     

    如下程序用于跟踪,在分配和回收都会触发探针

    #!/usr/sbin/dtrace -s

    pid$target:libc:malloc:entry
    {
        self->trace = 1;
        self->size = arg0;
    }
    pid$target:libc:malloc:return
    /self->trace == 1/
    {
        printf("Ptr=0x%p Size=%d", arg1, self->size);
        ustack();
        self->trace = 0;
        self->size = 0;
    }

    pid$target:libc:realloc:entry
    {
        self->trace = 1;
        self->size = arg1;
        self->oldptr = arg0;
    }

    pid$target:libc:realloc:return
    /self->trace == 1/
    {
        printf("Ptr=0x%p Oldptr=0x%p Size=%d", arg1, self->oldptr, self->size);
        ustack();
        self->trace = 0;
        self->size = 0;
    }

    pid$target:libc:calloc:entry
    {
        self->trace = 1;
        self->size = arg1;
    }

    pid$target:libc:calloc:return
    /self->trace == 1/
    {
        printf("Ptr=0x%p Size=%d", arg1, self->size);
        ustack();
        self->trace = 0;
        self->size = 0;
    }

    pid$target:libc:free:entry
    {
        printf("Ptr=0x%p ", arg0);
    }

    然后用perl程序将正常分配回收的去掉,剩下的就是有问题的调用了。

  • 相关阅读:
    [Violet]天使玩偶/SJY摆棋子
    语音识别终极教程
    语音识别
    转:awesome-lane-detection
    转:awesome-object-detection
    转:Awesome
    转:Awesome Image/Video segmentation
    转:目标检测算法总结
    转:10行代码实现物体检测
    转:词向量word2vector那些事儿
  • 原文地址:https://www.cnblogs.com/zengkefu/p/7502433.html
Copyright © 2011-2022 走看看