lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] memory leak in udp


From: Martin Glunz
Subject: [lwip-users] Re: [lwip] memory leak in udp
Date: Thu, 09 Jan 2003 00:13:57 -0000

> Hi David!
> 
> On Wednesday 30 January 2002 17.51, you wrote:
> > I'm losing memory as I run packets through the UDP path.  Should udp_init()
> > register reclaim functions as tcp_init() does?  What would that look like?
> 
> Are you using the raw API or the sequential API? If you are using the raw 
> API, the incoming pbufs must be deallocated with pbuf_free() when the 
> application is done with them, and the sequential API requires that 
> netbuf_delete() is called for incoming buffers. Perhaps that could be your 
> problem?
> 

I´ve experienced a similar problem:
When sending UDP Packets through the seq API there seems to be a
memory leak (lwip-0.5.3). 
Look at the following code:

  while (1) {
    printf("send udp %d\n",++i);
    conn=netconn_new(NETCONN_UDP);
    IP4_ADDR(&addr,192,168,3,3); port=514;
    netconn_connect(conn, &addr, port);
    #if 1
    buf=netbuf_new();
    netbuf_alloc(buf, 64);
    netconn_send(conn, buf);
    netbuf_delete(buf);
    #else
    buf=netbuf_new();
    netbuf_ref(buf,"Hello world\n",12);
    netconn_send(conn, buf);
    netbuf_delete(buf);
    #endif
    netconn_delete(conn);
    co_sleep(500);
  };

With the #if 1 it seems to run fine, without memory losses. But if
I change to #if 0 (netbuf_ref is used) it sends an amount of packets
and then stops (no more packets are sent), but the counter in
the printf() still runs.
When I look at the pbuf pointer that are passed to low_level_output()
there is a difference between netbuf_alloc() and netbuf_ref().
With netbuf_alloc() every Packet comes in one chunk from the
same adress, with netbuf_ref() the Packet comes in two chunks
with varying adresses.


-- 
Martin Glunz
[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]