使用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

相关文章:

  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2021-09-15
  • 2021-08-31
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案