This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Enhanced mtrace perl script to detect memory leaks in DSOs


 
 Hi 
 
I have been using libc's mtrace utility to detect simple memory leaks in my project related work. However I found that the usage of the mtrace perl script used to parse the mtrace.log file is limited to single executables only. By this I mean that if my program is dependent on a DSO and some leak is occuring inside that DSO then mtrace perl script is unable to detect it. Also the output of the mtrace perl script is not sorted in order of the leak size, thus making it difficult for the programmer to directly focus on big leaks.
    Keeping these limitations in mind I have enhanced the mtrace perl script so that it detects leaks occuring in DSOs as well and sorts them in descending order of size. The mtrace patch for the same is attached in the mail.
    The new script requires a file called mmapiinfo.log in the current working directory.This file contains the redirected output of cat /proc/<pid>/maps. If this file is not present then also the script will display the leaks but without the location information.

output of mtrace when mmapiinfo.log file is present:
Memory not freed:
-----------------
   Address     Size     Caller
0x00011400     0x28  at /home/shobhit/mtrace-0.1/testsuite/libmore.c:14
0x000113a0     0x28  at /home/shobhit/mtrace-0.1/testsuite/libHello.c:14
0x000113d0     0x14  at /home/shobhit/mtrace-0.1/testsuite/libHello.c:26
0x000113e8     0x14  at /home/shobhit/mtrace-0.1/testsuite/libmore.c:26
0x00011380      0x4  at /home/shobhit/mtrace-0.1/testsuite/hello.c:10
 
output of mtrace when mmapiinfo.log file is not present:
Memory not freed:
-----------------
   Address     Size     Caller
0x00011400     0x28  at 
0x000113a0     0x28  at 
0x000113d0     0x14  at 
0x000113e8     0x14  at 
0x00011380      0x4  at /home/shobhit/mtrace-0.1/testsuite/hello.c:10

 
I would appreciate your views regarding this and would like to hear from you soon.
 
Thanks and Regards
Shobhit Srivastava



Attachment: mtrace.patch
Description: Binary data

Attachment: ChangeLog
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]