S60 3rd下如何使用HookLogger查找内存泄漏错误?(转)

2024-01-27 11:32

本文主要是介绍S60 3rd下如何使用HookLogger查找内存泄漏错误?(转),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

近日,在一个S60 3rd的项目里,调试一个内存泄漏错误,总也找不到是哪里出了问题。想到以前曾碰到过一个HookLogger的工具可以检测内存泄漏,于是就下载过来。试用了一下效果相当不错,很快就找到了发生错误的位置。下面具体描述在S60 3rd环境下怎么安装与使用HookLogger:

1、下载:
http://developer.symbian.com/main/downloads/files/HookLogger_Setup.zip

2、安装:(假定使用的是S60 3rd MR版)
解压HookLogger_Setup.zip后运行安装程序,按默认安装。

在S60 3rd下使用HookLogger,稍微有些问题,修改如下:
1) 在系统的环境变量设置里,添加环境变量EPOCROOT,其值为/Symbian/9.1/S60_3rd_MR/
2) (可用记事本)打开文件
C:/Program Files/Common Files/Symbian/tools/HookEUSER.pl
替换
    my $cmd = "copy $hooks_src";

    my $cmd = "copy /"$hooks_src/"";
以及替换
    $cmd = "$Bin/AttachDll $euser $hooks $hooked_euser";

    $cmd = "/"$Bin/AttachDll/" $euser $hooks $hooked_euser";
保存后退出。
3)打开一个控制台(DOS窗口),改变当前目录为:
C:/Program Files/Common Files/Symbian/tools
然后运行
hookeuser winscw

3、使用:
先启动HookLogger,然后启动Emulator。运行你的程序,再现MemLeak直到异常退出。这时,转到HookLogger的Heap页,点击下面的按钮“List All Allocs”将列出发生内存泄漏的地址。然后双击某条信息即可查看明细情况,甚至可以打开源代码文件,非常方便!

详情可参考[注2]。

4、卸载:
参考2.3,运行
hookeuser -r winscw

评:HookLogger是一个好工具,在对内存泄漏毫无头绪时,可帮你迅速找到问题之所在。

[注1] http://developer.symbian.com/main/tools/devtools/code/index.jsp#debugging
[注2] http://www.symbian.net.cn/blog/post/5.html 

 

Use HookLogger to trace memroy leak in S60 3rd SDK

 

Link to download HoopLogger: http://developer.symbian.com/main/tools/devtools/code/index.jsp

The HookLogger application is a Windows GUI-based tool which provides easy journalling facilities for logging memory allocations, processes, thread  creation and leaves when executing an application under the Symbian OS Emulator. The main use for most developers is pin-pointing the source of a leaked  heap cell. This tool can be installed in any directory and monitors the execution of a Symbian application under any Symbian OS SDK. The user has to  issue a command in order to replace EUSER.DLL of the target Symbian OS SDK with a version that allows the attachment of "hooks" which are used by the  HookLogger tool. After the execution session is finished the user can issue the same command in order to restore the original version of EUSER.DLL.

This article demonstrates how to use the HoopLogger in S60 3rd SDK, refer to http://developer.sonyericsson.com/site/global/techsupport/tipstrickscode/symbian/p_hooklogger_trace_memory_leaks_uiq3.jsp to know about how to use it in UIQ3 SDK. OK, here we go!

First, you should download the software from the link above and install it. It's recommended that you install the software in the default directory. Then you have to tell "HoopLogger" what SDK she is working on, so you open a console window and input the command "HookEUSER winscw" ("HookEUSER wins" for Symbian v7.0 or below). This is done by modifying euser.dll, again, the user can issue the same command in order to restore the original version of the file.

However, usually you may meet some problems when you excuting this command. I met 2 actually. If you have the error code:

Failed setting cwd to epoc32/release/winscw/udeb at C:/Symbian/HookLogger/HookEUSER.pl line 54.

That is most likely to mean that your "EPOC ROOT" environment variable is not set properly. To get it right, you should set he epoc root as the diagram below(in this case, it's for S60 3rd SDK):

OK, let's go ahead. But you may meet the problem like:

The system cannot find the file specified.
Failed running "copy C:/Program Files/Common Files/Symbian/Tools/EUserParasite_eka1.dll" at C:/Program Files/Common Files/Symbian/Tools/HookEUSER.pl line 76.

This problem can be solved by modifying HookEUser.pl file. Open this and find the line

my $cmd = "copy $hooks_src";

Replace this by

my $cmd = "copy /"$hooks_src/"";

And locate the line

$cmd = "$Bin/AttachDll $euser $hooks $hooked_euser";

Replace this by

$cmd = "/"$Bin/AttachDll/" $euser $hooks $hooked_euser";

Then you are done, try to excute the command again, if the message below shows, then HoopLogger is ready.

Target path is /Symbian/9.1/S60_3rd_MR/epoc32/release/winscw/UDEB 1 file(s) copied.
Modified euser.dll to hook EUserParasite_eka2.dll, original is euser.orig.dll.
Run HookEUSER with -r to restore

 OK, now we open the IDE and make a little memory leak deliberately. We input the code like this:

TInt* i = new TInt;
 i = new TInt;
 delete i;

Compile the code and launch the HookLogger first and switch to the "thread" label, should be empty there. Then lauch the 3rd Emulator, you should see many running threads' info appear like the diagram below:

Then make the memory leak happen, record the error code(here's 250295e4), like this:

Next you choose all the threads in "thread" label then swith to "heap" label and click "list all allocs" button. Wait for a while then look for "250295e4" in "ptr"column like below:

Double click it and there will be a window poped:

Take a look at the line in blue, it indicates that the memory leak is caused by the code in line 44, Symbian1appui.cpp, check your source code, does it right? Cool ah...!

这篇关于S60 3rd下如何使用HookLogger查找内存泄漏错误?(转)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/650118

相关文章

中文分词jieba库的使用与实景应用(一)

知识星球:https://articles.zsxq.com/id_fxvgc803qmr2.html 目录 一.定义: 精确模式(默认模式): 全模式: 搜索引擎模式: paddle 模式(基于深度学习的分词模式): 二 自定义词典 三.文本解析   调整词出现的频率 四. 关键词提取 A. 基于TF-IDF算法的关键词提取 B. 基于TextRank算法的关键词提取

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

NameNode内存生产配置

Hadoop2.x 系列,配置 NameNode 内存 NameNode 内存默认 2000m ,如果服务器内存 4G , NameNode 内存可以配置 3g 。在 hadoop-env.sh 文件中配置如下。 HADOOP_NAMENODE_OPTS=-Xmx3072m Hadoop3.x 系列,配置 Nam

Hadoop数据压缩使用介绍

一、压缩原则 (1)运算密集型的Job,少用压缩 (2)IO密集型的Job,多用压缩 二、压缩算法比较 三、压缩位置选择 四、压缩参数配置 1)为了支持多种压缩/解压缩算法,Hadoop引入了编码/解码器 2)要在Hadoop中启用压缩,可以配置如下参数

Makefile简明使用教程

文章目录 规则makefile文件的基本语法:加在命令前的特殊符号:.PHONY伪目标: Makefilev1 直观写法v2 加上中间过程v3 伪目标v4 变量 make 选项-f-n-C Make 是一种流行的构建工具,常用于将源代码转换成可执行文件或者其他形式的输出文件(如库文件、文档等)。Make 可以自动化地执行编译、链接等一系列操作。 规则 makefile文件

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传

pdfmake生成pdf的使用

实际项目中有时会有根据填写的表单数据或者其他格式的数据,将数据自动填充到pdf文件中根据固定模板生成pdf文件的需求 文章目录 利用pdfmake生成pdf文件1.下载安装pdfmake第三方包2.封装生成pdf文件的共用配置3.生成pdf文件的文件模板内容4.调用方法生成pdf 利用pdfmake生成pdf文件 1.下载安装pdfmake第三方包 npm i pdfma

零基础学习Redis(10) -- zset类型命令使用

zset是有序集合,内部除了存储元素外,还会存储一个score,存储在zset中的元素会按照score的大小升序排列,不同元素的score可以重复,score相同的元素会按照元素的字典序排列。 1. zset常用命令 1.1 zadd  zadd key [NX | XX] [GT | LT]   [CH] [INCR] score member [score member ...]

git使用的说明总结

Git使用说明 下载安装(下载地址) macOS: Git - Downloading macOS Windows: Git - Downloading Windows Linux/Unix: Git (git-scm.com) 创建新仓库 本地创建新仓库:创建新文件夹,进入文件夹目录,执行指令 git init ,用以创建新的git 克隆仓库 执行指令用以创建一个本地仓库的

【北交大信息所AI-Max2】使用方法

BJTU信息所集群AI_MAX2使用方法 使用的前提是预约到相应的算力卡,拥有登录权限的账号密码,一般为导师组共用一个。 有浏览器、ssh工具就可以。 1.新建集群Terminal 浏览器登陆10.126.62.75 (如果是1集群把75改成66) 交互式开发 执行器选Terminal 密码随便设一个(需记住) 工作空间:私有数据、全部文件 加速器选GeForce_RTX_2080_Ti