How to Use hooklogger to find Memory leakage in the vc6 + Symbian 2 SDK Development Environment
1. Download hooklogger for free. We recommend that you install it on disk C. (Google it. The link provided now may not be available for download .)
2. Configure hooklogger. In fact, you do not need to configure epocroot environment variables, and directly overwrite the following content to C:/program files/common files/Symbian/tools/hookeuser. the PL (installation path will be different) files are all overwritten.
Note that the key 53rd rows: My $ Path = "/Symbian/7.0 S/series60_v21_c/epoc32/release/wins/udeb"; the path must be consistent with your own, otherwise, modify it.
The content of hookeuser. pl is as follows:
# Hookeuser. PL use strict; Use findbin QW ($ bin); my $ badarg = 0; my $ remove = 0; my $ platform; my $ release = "udeb"; my $ arch; if ($ # argv> = 0) {my $ Arg = 0; if ($ argv [0] = ~ M! ^ [-/] R$! I) {$ remove = 1; ++ $ ARG;} if ($ # argv >=$ Arg & $ argv [$ Arg] = ~ /^ Wins (CW )? $/I) {$ platform = $ argv [$ Arg]; $ arch = ($ platform = ~ /^ Wins $/I )? "Eka1": "eka2"; ++ $ ARG;} while ($ # argv >=$ Arg & $ argv [$ Arg] = ~ /^ (Udeb | urel | eka1 | eka2) $/I) {if ($ argv [$ Arg] = ~ /^ (Udeb | urel) $/I) {$ release = $ argv [$ Arg];} else {$ arch = $ argv [$ Arg];} + + $ Arg ;}$ badarg = ($ # argv >=$ Arg);} if ($ badarg |! Defined ($ platform) {print <usage_eof; usage: hookeuser. PL [-R] <platform> [release] [arch] Where: <platform >== wins | winscw [release] = udeb | urel (default = udeb) [arch] = eka1 | eka2 (default = eka1 for wins, eka2 for winscw)-R restores original euser. dllusage_eof exit (0);} My $ Path = "/Symbian/7.0 S/series60_v21_c/epoc32/release/wins/udeb"; chdir ($ PATH) or die "failed setting CWD to $ path"; My $ euser = "euser. DLL "; my $ euser_orig =" euser. orig. DLL "; my $ hooks =" euserparasite _ $ arch. DLL "; my $ hooks_src =" $ bin/$ hooks "; die" can't find/"$ hooks_src/" "unless-e $ hooks_src; print "target path is $ path/N"; die "can't find/" $ euser/"-wrong drive, arguments, or epocroot env var? "Unless-e $ euser; if ($ remove) {die" can't find/"$ euser_orig/"-was euser. dll hooked by this script? "Unless-e $ euser_orig; unlink $ euser or die" can't delete hooked euser. dll-Is emulator (ETC) running? "; Rename ($ euser_orig, $ euser) or die" failed renaming $ euser_orig to $ euser "; print" restored $ euser from $ euser_orig; hooks no longer in place/N ";} else {die"/"$ euser_orig/" present-has euser. DLL already been hooked? "If-e $ euser_orig; my $ hooked_euser =" $ euser. hooked "; unlink $ hooked_euser; # earlier attempt may have died with" in use ", etc my $ cmd =" copy/"$ hooks_src/"; $ cmd = ~ Tr-/-//-; system ($ cmd) = 0 or die "failed running/" $ cmd /""; $ cmd = "/" $ bin/attachdll/"$ euser $ hooks $ hooked_euser"; system ($ cmd) = 0 or die "failed running/" $ cmd/""; rename $ euser, $ euser_orig or die "failed renaming $ euser to $ euser_orig-Is emulator (ETC) running? "; Rename $ hooked_euser, $ euser or die" failed renaming $ hooked_euser to $ euser "; print" modified $ euser to hook $ hooks, original is $ euser_orig. /nrun hookeuser with-R to restore/N ";}
3. Enter the path C:/program files/common files/Symbian/tools/In the doscommand status, enter: hookeuser wins, and press Enter. One file copy prompt, indicating that it is OK.
4. How to use it? Start hooklogger first, then start the simulator, run your program with Memory leakage, and then enter the heap tab of hooklogger, click list all... button, wait for a long time, then click the PTR column to sort, then find the memory address popped up by panic, double-click to see. The source code that causes memory leakage is found. You can easily solve the problem by analyzing your program.