使用google-perftools的tcmalloc

使用google-perftools的tcmalloc
安装
使用
export LD_PRELOAD="/usr/local/lib/libtcmalloc.so"

cat testMalloc.cpp & g++ testMalloc.cpp & ./a.out

#include <stdio.h>
#include <memory.h>
#include <stdlib.h>

int main()
{
        void *p=malloc(100);
        printf("stop here\n");
        getchar();
        free(p);
}

使用lsof命令查看tcmalloc是否起效
cutepig@ubuntu:~$ lsof -n |grep tcmalloc
a.out      5501    cutepig  mem       REG        8,1  1645060     206764 /usr/local/lib/libtcmalloc.so

posted on 2012-01-14 00:20  cutepig  阅读(716)  评论(0编辑  收藏  举报

导航