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

相关文章

C++使用栈实现括号匹配的代码详解

《C++使用栈实现括号匹配的代码详解》在编程中,括号匹配是一个常见问题,尤其是在处理数学表达式、编译器解析等任务时,栈是一种非常适合处理此类问题的数据结构,能够精确地管理括号的匹配问题,本文将通过C+... 目录引言问题描述代码讲解代码解析栈的状态表示测试总结引言在编程中,括号匹配是一个常见问题,尤其是在

Java中String字符串使用避坑指南

《Java中String字符串使用避坑指南》Java中的String字符串是我们日常编程中用得最多的类之一,看似简单的String使用,却隐藏着不少“坑”,如果不注意,可能会导致性能问题、意外的错误容... 目录8个避坑点如下:1. 字符串的不可变性:每次修改都创建新对象2. 使用 == 比较字符串,陷阱满

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

C++ Primer 多维数组的使用

《C++Primer多维数组的使用》本文主要介绍了多维数组在C++语言中的定义、初始化、下标引用以及使用范围for语句处理多维数组的方法,具有一定的参考价值,感兴趣的可以了解一下... 目录多维数组多维数组的初始化多维数组的下标引用使用范围for语句处理多维数组指针和多维数组多维数组严格来说,C++语言没