Categories: How To | Tools | Debugging
This page was last modified 16:03, 3 June 2008.
Detecting memory leaks with HookLogger
From Forum Nokia Wiki
It is one of the most time consuming task for developers to find memory leaks in their code. If your application happens to panic on exit with some memory leak, then sometimes it is a hard work to find the wrong piece of code with code analysis. HookLogger is a great emulator tool by Symbian that helps finding the leak fast.
Contents |
How does HookLogger work?
This tool replaces EUSER.DLL with its own to enable logging of memory allocations, process and thread creation, leaves, etc. HookLogger application collects these logs and presents them to the user in an easily readable form.
Installation
HookLogger can be downloaded here. It has a convenient installer.
Notes:
- HookLogger's installation path must not contain any spaces. If it does (e.g. installing to the default location under Program Files\Common Files\Symbian\tools), you will have to edit two lines at the end of HookEUSER.pl. Replace
Line Number: 74 my $cmd = "copy $hooks_src";
withmy $cmd = "copy \"$hooks_src\"";
andLine Number : 77 $cmd = "$Bin/AttachDll $euser $hooks $hooked_euser";
with$cmd = "\"$Bin/AttachDll\" $euser $hooks $hooked_euser";
- S60 platform's installation path must not contain any spaces. This is not a severe issue as almost all tools in the Symbian toolchain have this limitation in any case.
Of course, you can also replace EUSER.DLL manually.
You migth need to add following line to project .mmp files if HookLogger call stack display is not correct:OPTION CW -frame on.
Usage
1. There is a script provided with HookLogger to do that. Open a command line in HookLoggers's installation folder and type:
HookEUSER winscw
After this one might get this kind of error
C:\Program Files\Common Files\Symbian\tools>HookEUSER winscw Target path is C:\Symbian\9.1\S60_3rd_MR\epoc32/release/winscw/UDEB
1 file(s) copied.
'C:/Program' is not recognized as an internal or external command, operable program or batch file. Failed running "C:/Program Files/Common Files/Symbian/tools/AttachDll euser.dll EUserParasite_eka2.dll euser.dll.HOOKED" at HookEUSER.pl line 78. at line 78 one can set the path of the sdk that he might be working on
my $path = "C:/Symbian/9.1/S60_3rd_MR/Epoc32/release/$platform/$release";
or you can set the epocroot path Note, this perl script requires EPOCROOT environment variable to be set. E.g.:
set EPOCROOT=S:\Symbian\9.2\S60_3rd_FP1\
2. Start HookLogger from Start menu.
3. Select 'Filters' tab and press 'Browse for EXE' button and find your leaking executable you want to analyze. In the combo box select 'Include only checked'.
4. Start the emulator.
5. Start your application in the emulator, reproduce the memory leak, then close it.
6. Check HookLogger's 'Heap' tab then press 'List all allocs' button.
You will see the list of leaked data. With 'Alloc details' you get all the information you need: The call stack, when the leaked memory was allocated!
Note!
Remember to restore old EUSER.DLL after using HookLogger, since the modified one is slow and uses lot's of resources!
HookEUSER -r winscw
Internal Links
External Links
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Memory profiler for J2ME | darshanbildikar | Mobile Java General | 3 | 2007-10-31 12:18 |
| Checking Memory Leaks in 3rd Edition | mateen_maldar | Symbian User Interface | 1 | 2006-11-02 10:44 |
| How can I get the total memory size? | eyalmnm | General Symbian C++ | 1 | 2007-01-13 10:20 |
| Memory leak detection | kdallan | General Symbian C++ | 3 | 2004-02-06 19:49 |
| Camera Application Engine API vs sdk Camera API | nuker85 | Symbian Media (Graphics & Sounds) | 5 | 2008-07-04 11:55 |
