[Serdev] Finding a memory leak
Andrei Pelinescu-Onciul
andrei at iptel.org
Wed Apr 12 15:34:09 UTC 2006
On Apr 12, 2006 at 13:57, Pupeno <pupeno at pupeno.com> wrote:
> Hello,
> I am trying to see if my module for SER has a memory leak, so I've set
> memlog to 2 and now I have tons of messages about memory.
> Doing a bit of search I've found things such as:
>
> 2(12621) 403. N address=0x813b3d8 frag=0x813b3c0 size=4 used=1
> 2(12621) alloc'd from dialplan.c: mod_init(199)
> 2(12621) start check=f0f0f0f0, end check= c0c0c0c0, abcdefed
>
> but as far as I know this is not sign of a memory leak, right ?
This means this fragment is still allocated at the time of the dump.
If this "memory dump" happened on ser shutdown, it means that nobody
freed this fragment. This could be a memory leak or a harmless missing
free on ser exit/mod destroy.
For easier debugging and saner code is recommended to free all the
memory allocated during init (mod_init, init_child) in the module's
destroy function.
> What should I be looking for ?
You should check all the allocated fragments displayed on ser's
exit (like above) and originating from your module (some of them could
be real memory leaks).
If you want to get only the big "offenders", look for duplicates in the
mem. status dump (the same allocation which appears several times).
E.g.:
2(12621) 403. N address=0x813b3d8 frag=0x813b3c0 size=4 used=1
2(12621) alloc'd from dialplan.c: mod_init(199)
^^^^^^^^^^^^^^^^^^^^^^^^^
....
2(12621) 403. N address=0xNNNNNN frag=0xNNNNNNN size=4 used=1
2(12621) alloc'd from dialplan.c: mod_init(199)
^^^^^^^^^^^^^^^^^^^^^^^^^
You can use grep, sed, sort and uniq to get only the duplicates.
Andrei
More information about the Serdev
mailing list