[Top][All Lists]

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

Re: [lwip-users] memp_malloc is NULL

From: Emmanuel Baguia Jr.
Subject: Re: [lwip-users] memp_malloc is NULL
Date: Sun, 21 Dec 2008 22:42:03 -0800 (PST)

Thank you very much for the input.
I manage to see the error with the memp_malloc. Actually the problem was the maximum number of netbuf defined somewhere in the lwip\lwipopts.h is much smaller to the number of reponses being received from the http_server.
At first, the max defined was 1, and the number of responses the http_client receives is 2. So the 2nd response is NULL in the netconn_recv(). Then I tried increasing the MEMP_NUM_NETBUF to something like 20. Then my application worked, but when I reached the 21st reponse, I got the same issue. What I was missing is having a netbuf_delete() function after every use of the netbuf during netconn_recv. Something like this:
while( ( inBuf = netconn_recv( conn ) ) != NULL )
    // do something with the data recvd
    netbuf_delete( inBuf ); //cleans up the netbuf after every reponse recv
Then everything went well.

--- On Tue, 12/16/08, Jonathan Larmour <address@hidden> wrote:
From: Jonathan Larmour <address@hidden>
Subject: Re: [lwip-users] memp_malloc is NULL
To: address@hidden, "Mailing list for lwIP users" <address@hidden>
Date: Tuesday, December 16, 2008, 8:48 AM

Emmanuel Baguia Jr. wrote:
> Hi all,
> Good day.
> The problem last time with my netconn_recv() issue not receiving
(blocking), was because the memp_malloc(MEMP_BUF) was not actually allocating
space. It is returning NULL value. There is this one forum that is discussing
about netconn_recv() blocking. It is somehow referring to process using the same
MEMP_BUF and by the time another process is going to use or create another
MEMP_BUF, it is not being released by the current process. There is a suggestion
to increase the MEMP_NUM_PBUF, but still getting the same NULL value. Am I
getting the exact solution here? Or may be miss something that needs to be done?

Do you mean you are running out of netbufs? or pbufs?

It could be you have a memory leak, perhaps due to a bug in your application, a
misuse of the lwIP API or a bug in lwIP. Try and increase the number
(MEMP_NUM_PBUF for pbufs, MEMP_NUM_NETBUF for netbufs) to a very large amount if
you can, and see if you still run out. You do this in lwipopts.h. While
you're there, you could usefully enable the lwIP statistics with LWIP_STATS
and watch the real usage.

But if you're talking about pbufs, it is possible you are just trying to
receive lots of data quicker than you can process it, and so run out of
pbufs.... with the netconn and sockets API the data can get buffered
indefinitely, even if you have a small TCP receive window (although it's
probably worth ensuring you do only have a small TCP window - that will limit
how much data a remote peer can send until it's been processed by the
stack). If this situation is going to arise frequently and you can't deal
with running out of pbufs, then you may have to adjust your port to limit the
capacity of mboxes.

But on rereading your description I think you are more likely to be talking
about netbufs.

-- eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["The best things in life aren't things."]------     

reply via email to

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