Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory leak detection mechanism-Linux device driver

162 views
Skip to first unread message

Manoj

unread,
Dec 14, 2003, 9:39:27 PM12/14/03
to
Hi
Is there any tools available in linux to detect memory leak
in device driver??

I have read posting like,taking a count of kmalloc() and kfree()..

Any other methods??

Kasper Dupont

unread,
Dec 15, 2003, 1:19:46 AM12/15/03
to
Manoj wrote:
>
> Hi
> Is there any tools available in linux to detect memory leak
> in device driver??

I have a few suggestions, but not actually any tools:
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#memleak

There might exist some tools. Some people have written
programs to perform analysis of the source code. They
sometimes post comments to the kernel mailing list with
results. But so far I don't think they have general
leak detection, only some special cases:

http://www.google.com/groups?selm=wfNh.6L9.11%40gated-at.bofh.it

I don't know if the tools are available to the public.

>
> I have read posting like,taking a count of kmalloc() and kfree()..
>
> Any other methods??

Well, first of all kmalloc and kfree are not the only
way to allocate memory. What would be interesting is to
keep track of which source line was responsible for
every current memory allocation. Of course such tracking
will have a cost in terms of both time and memory usage.

--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use mailto:aaa...@daimi.au.dk
/* Would you like fries with that? */

Manoj

unread,
Dec 15, 2003, 5:08:54 AM12/15/03
to
Kasper Dupont <kas...@daimi.au.dk> wrote in message news:<3FDD5282...@daimi.au.dk>...

> Manoj wrote:
> >
> > Hi
> > Is there any tools available in linux to detect memory leak
> > in device driver??
>
> I have a few suggestions, but not actually any tools:
> http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#memleak
>
> There might exist some tools. Some people have written
> programs to perform analysis of the source code. They
> sometimes post comments to the kernel mailing list with
> results. But so far I don't think they have general
> leak detection, only some special cases:
>
> http://www.google.com/groups?selm=wfNh.6L9.11%40gated-at.bofh.it
>
> I don't know if the tools are available to the public.
>
> >
> > I have read posting like,taking a count of kmalloc() and kfree()..
> >
> > Any other methods??
>
> Well, first of all kmalloc and kfree are not the only
> way to allocate memory. What would be interesting is to
> keep track of which source line was responsible for
> every current memory allocation. Of course such tracking
> will have a cost in terms of both time and memory usage.


Hi kasper ,
Thanks for post.
I have gone through the links,first one i have seen it..
Second one,not much useful for my purpose.
Any way let me check how can i track each and every memory allocations.
Good luck.
Thnks again.

Neil Horman

unread,
Dec 15, 2003, 8:37:36 AM12/15/03
to
Usually, if I'm trying to pinpoint memory leaks in kernel space code, I
write some of my own routines to do it. I wrap up any call that
allocates memory in a function that registers the call address allong
with a descriptive message on a linked list, and wrap up all the calls
that deallocate memory with functions that remove the requisite address
"key" from the linked list. Then I just export the list via a proc
file. Its not real good for high performance scenarios, but it gets the
job done, as over time, I can simply cat the proc file, and see
allocation patterns emerge, as well as entries which entered the list,
but never exited (read: potential leaks).

HTH
Neil

--
Neil Horman
Red Hat, Inc., http://people.redhat.com/nhorman
gpg keyid: 1024D / 0x92A74FA1, http://www.keyserver.net

0 new messages