Re: Finding memory leak

From: Holger Kiehl
Date: Sat Oct 18 2003 - 12:02:39 EST


On Wed, 15 Oct 2003, Andrew Morton wrote:

> Holger Kiehl <Holger.Kiehl@xxxxxx> wrote:
> >
> > - Is it correct to assume that an application cannot be the cause
> > of the leak, ie. it can only be in kernel or a driver?
>
> Yes.
>
> > - How can I really prove that its the driver leaking the memory?
>
> Look for instances of kmalloc(n, ...) for n in the range 1025 to 2048 which
> do not have a matching kfree.
>
Could only find two instances one allocating 14 bytes and the other 4096.
Looking further I found several calls of dev_alloc_skb(). But I assume
these calls are also not the cause, because I put in some printk and
the size-2048 values do not go up when this is called.

Since the only thing running at that time is some application that receives
a multicast stream from the DVB card and writes the data to the disk, I put
in printk's at every kmalloc() or allocation functions in net/core and
net/ipv4. After many trials I could narrow this down to every time the
function igmpv3_newpack() in net/ipv4/igmp.c is called. This is always
called twice very quickly (there where never any other printk's between
these two calls). The size allocated by alloc_skb() in igmpv3_newpack()
when size-2048 in slabinfo goes up is 1529 bytes (in skbuff.c this allocates
1596 bytes).

The kernel network code is way beyond my knowledge and I cannot determine
how it frees up the memory again. Also, it is very very likely that the leak
is at some completely different place and igmpv3_newpack() is just called
shortly before or afterwards.

So the questions I have are:

- Could someone please check igmpv3_newpack() and assure me that there
is no leak.

- Are there any tools or kernel switches that I can use that allow me
to capture the leak faster? Currently I am using 2.4.22.

- Which system call might cause a igmpv3_newpack().

Thanks,
Holger

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/