例子:

malPro.acc文件:

#include <stdlib.h>
size_t totalMemoryAllocated;
int totalAllocationFuncCalled;
int totalFreeFuncCalled;

void initProfiler() {
totalMemoryAllocated = 0;
totalAllocationFuncCalled = 0;
totalFreeFuncCalled = 0;
}

void printProfiler() {
printf("total memory allocated = %d bytes\n", totalMemoryAllocated );
printf("total memory allocation function called = %d \n", totalAllocationFuncCalled);
printf("total memory free function called = %d\n", totalFreeFuncCalled);
}

before(): execution(int main()) {
initProfiler();
}
after(): execution(int main()) {
printProfiler();
}

before(size_t s): call($ malloc(...)) && args(s) {
totalMemoryAllocated += s;
totalAllocationFuncCalled ++;
}
before(size_t n, size_t s): call($ calloc(...)) && args(n, s) {
totalMemoryAllocated += n * s;
totalAllocationFuncCalled ++;
}

before(size_t s): call($ realloc(...)) && args(void *, s) {
totalMemoryAllocated += s;
totalAllocationFuncCalled ++;
}

before() : call(void free(void *)) {
totalFreeFuncCalled++;
}

mal.c文件:

#include <stdio.h>
#include <malloc.h>
void t1()
{
int *x ;
printf(" core code:hehe ! \n");
x = (int *)malloc(sizeof(int) * 4);
printf(" core code:hehe ! ! \n");
}
int main()
{
t1();
int *x ;
printf(" core code:hehe ! ! \n");
x = (int *)malloc(sizeof(int) * 4);
printf(" core code:hehe ! ! \n");
return 0;
}

A Reusable Aspect for Memory Profiling的更多相关文章

  1. A Reusable Aspect for Memory Allocation Checking

    The checking logic would be refactored into an aspect file, as follows: after(void * s) : (call($ ma ...

  2. .NET Memory Allocation Profiling with Visual Studio 2012

    .NET Memory Allocation Profiling with Visual Studio 2012 This post was written by Stephen Toub, a fr ...

  3. Reducing and Profiling GPU Memory Usage in Keras with TensorFlow Backend

    keras 自适应分配显存 & 清理不用的变量释放 GPU 显存 Intro Are you running out of GPU memory when using keras or ten ...

  4. 32 Profiling Go Programs 分析go语言项目

    Profiling Go Programs  分析go语言项目 24 June 2011 At Scala Days 2011, Robert Hundt presented a paper titl ...

  5. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  6. Android APP性能分析方法及工具

    近期读到<Speed up your app>一文.这是一篇关于Android APP性能分析.优化的文章.在这篇文章中,作者介绍他的APP分析优化规则.使用的工具和方法.我觉得值得大家借 ...

  7. XHProf中文手册

    目录 导言 XHProf 概况 安装XHProf扩展 使用XHProf进行性能分析 设置XHProf用户界面 在生产环境中使用XHProf注意事项 轻量级采样模式 附加功能 信赖 鸣谢 导言 XHPr ...

  8. Chrome开发者工具之JavaScript内存分析

    阅读目录 对象大小(Object sizes) 对象的占用总内存树 支配对象(Dominators) V8介绍 Chrome 任务管理器 通过DevTools Timeline来定位内存问题 内存回收 ...

  9. [转载]JavaScript内存分析

    https://github.com/CN-Chrome-DevTools/CN-Chrome-DevTools/blob/master/md/Performance-Profiling/javasc ...

随机推荐

  1. 大白_uva10795_新汉诺塔

    题意:给出所有盘子的初态和终态,问最少多少步能从初态走到终态,其余规则和老汉诺塔一样. 思路: 若要把当前最大的盘子m从1移动到3,那么首先必须把剩下的所有盘子1~m-1放到2上,然后把m放到3上. ...

  2. 扩增子图表解读3热图:差异菌、OTU及功能

    热图是使用颜色来展示数值矩阵的图形.通常还会结合行.列的聚类分析,以表达实验数据多方面的结果.  热图在生物学领域应用广泛,尤其在高通量测序的结果展示中很流行,如样品-基因表达,样品-OTU相对丰度矩 ...

  3. ubuntu.16.04 安装.net core记录

    jack@ubuntu:~$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotne ...

  4. 汇编:MSR/MRS/BIC指令

    1.MRS指令MRS指令的格式为:MRS{条件}   通用寄存器,程序状态寄存器(CPSR或SPSR)MRS指令用于将程序状态寄存器的内容传送到通用寄存器中.该指令一般用在以下两种情冴: Ⅰ.当需要改 ...

  5. 最新 Xilinx vivado IP许可申请

    xilinx的fpga使用vivado开发,zynq系列fpga的SOC开发成为主流,加快fpga开发,也进一步提高了fpga开发的灵活性. xilinx提供很多ip核供开发者直接使用,开发快捷方便, ...

  6. Entertainment Box Gym100781E(数据结构+贪心)

    Entertainment Box 题意: 有n个节目,每个节目给出开始时间(st)和结束时间(en): 有k个内存条这k个内存条可以同时存储节目.如果节目j的开始时间stj  大于等于节目i的结束时 ...

  7. SpringMVC demo 小例子,实现简单的登录和注册

    1.创建一个动态的web工程 2.导入springMvc所需要的jar包(这里可以去网上找,资源有很多) 前两部就不详细描述了,后面才是正经代码~ 首先有一个web.xml文件,这个属于大配置文件,由 ...

  8. hdu2016 数据的交换输出【C++】

    数据的交换输出 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  9. Awesome Python(中文对照)

    python中文资源大全:https://github.com/jobbole/awesome-python-cn A curated list of awesome Python framework ...

  10. sql server使用杂记

    SqlServer导出数据库 navcat for sql server中打开连接,打开数据库,右键--数据传输,常规选项卡--模式选择dbo,目标选择连接(选择你新建的库)或者文件(导出你要的sql ...