VS2013编译gperftools-2.4

1)https://github.com/gperftools/gperftools  下载   gperftools-2.4.zip  版本。
2)解压 gperftools-2.4.zip,保留Debug,src,vsprojects文件夹 及gperftools.sln工程文件,其他删除。
3)vsprojects 文件夹下,只保留libtcmalloc_minimal文件夹,其他文件夹删除。
4)编译项目动态库libtcmalloc_minimal.dll

 

vs2013工程Vc++  目录-》包含目录中  
添加 ../gperftools-gperftools-2.4/src/windows/gperftools
在连接-》输入-》 中
添加libtcmalloc_minimal-debug.lib 

 

 在stdafx.h中添加

 //使用tcmalloc分配器
 #define USE_TCMALLOC_LIB
 #ifdef USE_TCMALLOC_LIB
 #include "tcmalloc.h"
 #endif // USE_TCMALLOC_LI

 

 

 在项目app中测试调用是否成功
int main(int argc, char* argv[])
{
   const char* tcVer = tc_version(NULL, NULL, NULL);
  if (NULL != tcVer)
         printf("%s \n", tcVer);
  
   return 0;
}

 

相关文章: