lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] lwIP malloc fail


From: Navcon - Pedro Paulo Santos
Subject: [lwip-users] lwIP malloc fail
Date: Tue, 6 Apr 2010 12:38:19 -0300

Hi all!
 
I'm having a problem in trying to make a system with lwIP that sends a large file with TCP from an external serial Flash memory.
 
I use the following logic: read certain amont of data from the external memory, send over TCP with tcp_write (), read more data, send again, and there goes on. I made a function to handle lack of memory because of Nagle's algoritm (because I have little memory and can't prepare a large TCP message), and use tcp_output () to force the send of the amont of data. The problem is that after some transfers (no more than 15 tcp transfers) the program doesn't find memory to alloc in the following lines of tcp_enqueue () function:
 
    /* Allocate memory for tcp_seg, and fill in fields. */
    seg = memp_malloc(MEMP_TCP_SEG);
    if (seg == NULL) {
      LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for tcp_seg\n"));
      goto memerr;
    }
 
In my thinking, the tcp_output () function should free memory for the further transfers so that I can transfer any amont of data if I make a lot of consecutive "small" transfers.
 
It occurs even if I send really small messages, with 20 bytes, for example. I already tried to edit lwipopts.h raising TCP_SND_BUF, TCP_WND, TCP_MSS, PBUF_POOL_SIZE, MEM_SIZE... but I got no good results.
 
Do I have to free memory, myself, in any part of the lwIP implementation?
(I already free the pbuf that my recv function returns as callback after the read)
 
Anyone have a suggestion of what could be the problem?
 
Informations: I'm using an ARM microcontroller with 64kB SRAM and 256kB flash. I already made an HTTP server into it, but it spends very little memory. My external serial (SPI) flash memory have 128MB.
 
Thanks to all!
 
Pedro Paulo.


__________ Informação do ESET NOD32 Antivirus, versão da vacina 4628 (20091122) __________

A mensagem foi verificada pelo ESET NOD32 Antivirus.

http://www.eset.com

reply via email to

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