A Reusable Aspect for Memory Profiling
例子:
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的更多相关文章
- A Reusable Aspect for Memory Allocation Checking
The checking logic would be refactored into an aspect file, as follows: after(void * s) : (call($ ma ...
- .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 ...
- 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 ...
- 32 Profiling Go Programs 分析go语言项目
Profiling Go Programs 分析go语言项目 24 June 2011 At Scala Days 2011, Robert Hundt presented a paper titl ...
- Java性能提示(全)
http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...
- Android APP性能分析方法及工具
近期读到<Speed up your app>一文.这是一篇关于Android APP性能分析.优化的文章.在这篇文章中,作者介绍他的APP分析优化规则.使用的工具和方法.我觉得值得大家借 ...
- XHProf中文手册
目录 导言 XHProf 概况 安装XHProf扩展 使用XHProf进行性能分析 设置XHProf用户界面 在生产环境中使用XHProf注意事项 轻量级采样模式 附加功能 信赖 鸣谢 导言 XHPr ...
- Chrome开发者工具之JavaScript内存分析
阅读目录 对象大小(Object sizes) 对象的占用总内存树 支配对象(Dominators) V8介绍 Chrome 任务管理器 通过DevTools Timeline来定位内存问题 内存回收 ...
- [转载]JavaScript内存分析
https://github.com/CN-Chrome-DevTools/CN-Chrome-DevTools/blob/master/md/Performance-Profiling/javasc ...
随机推荐
- maven常用dos命令
在平常的开发中可能会经常切换开发中的一些工具,有时就会对一些常用的命令给忘记了 这里特别记录下来方便以后使用: 1.查看maven版本:mvn -c 2.一件构建启动Tomcat:mvn tomcat ...
- sysbench_cpu
5 core : 25.2848s [root@jiangyi01.sqa.zmf /home/ahao.mah/ALIOS_QA/tools/sysbench] #sysbench --num-th ...
- pandas - 案例(美国2012年总统候选人政治献金数据分析)
# 提供数据 months = {'JAN' : 1, 'FEB' : 2, 'MAR' : 3, 'APR' : 4, 'MAY' : 5, 'JUN' : 6, 'JUL' : 7, 'AUG' ...
- String formatting in Python
| \n | 换行 || \t | 制表符 || \ | 转义 || \\ | \ | the '%' operator is used to format a set of va ...
- 解析 XML 数据
在几个月前我有做过这样的记录,其目的是避免解析 XML 时手工编写太多的代码,造成重复的体力劳动.后来经过一番资料的查找,我发现其实并没有必要做这样的工具,因为 C# 已经为我们提供了更好的解决方案了 ...
- GlobalSign 增强型(EV) SSL 证书
GlobalSign 增强型(EV) SSL 证书,属于最高验证级别的EV SSL,验证域名所有权,进行严格的企业真实身份验证,证书标识企业组织机构名称,强化信任度,浏览器地址栏变绿色.提供40位/5 ...
- (39.1) Spring Boot Shiro权限管理【从零开始学Spring Boot】
(本节提供源代码,在最下面可以下载)距上一个章节过了二个星期了,最近时间也是比较紧,一直没有时间可以写博客,今天难得有点时间,就说说Spring Boot如何集成Shiro吧.这个章节会比较复杂,牵涉 ...
- EXt js 学习笔记总结
1. get . fly. getCmp .getBody .getDoc .getDom.. get-----ExtJs获取节点.dom.提供缓存机制 Ext.Element类是Ext对DO ...
- class类加载机制
1.类的加载过程 a.加载-链接-初始化-使用-卸载 加载: 查找并加载类的二进制数据 链接: 验证类的正确性,为类的静态变量分配内存,并将其初始化为默认值,把类的符号引用转换为直接引用. 初始化: ...
- [bzoj2783][JLOI2012]树_树的遍历
树 bzoj2783 JLOI2012 题目大意:给定一棵n个点的树.求满足条件的路径条数.说一个路径是满足条件的,当且仅当这条路径上每个节点深度依次递增且点权和为S. 注释:$1\le n\le 1 ...