lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] DHCP + mem_malloc / pbuf allocation from ram (not the pool)


From: Eric Shufro
Subject: [lwip-users] DHCP + mem_malloc / pbuf allocation from ram (not the pool)
Date: Sat, 18 Sep 2004 19:18:11 -0400

When I start DHCP, I sends a discovery and then receives an offer, but it
never sends a request since when it tries to allocate memory for the dhcp
request, an error is returned: not enough memory.

The error's origin is in dhcp.h, function dhcp_create_request() when it
calls:

dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM);


So after some tracing, I determined that increasing the number of pbufs in
the pool wouldn't fix this because the source is RAM and not the pbuf pool.

Is this assumption correct?

What kind of other things can I reduce in order to free memory for this?

I currently have ~2kB ram free - its cutting it very very close :)

This is a list of most of the memory options from the lwipopt.h.

Should I try to reduce the count of pbufs and other things to increase the
amount of available general ram, or should I be increasing the amount of
pbufs in the pool?

Im a bit confused, looks like more pbufs in the pool is not the answer.

Please advise,

Thanks 

Eric Shufro



/* ---------- Memory options ---------- */
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
   lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
   byte alignment -> define MEM_ALIGNMENT to 2. */
#define MEM_ALIGNMENT           1

/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE               500  //changed was 10240  or 1600 

/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
   sends a lot of data out of ROM (or other static memory), this
   should be set high. */
#define MEMP_NUM_PBUF           2 //changed was 16
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
   per active UDP "connection". */
#define MEMP_NUM_UDP_PCB        4
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
   connections. */
#define MEMP_NUM_TCP_PCB        3 //changed was 5
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
   connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 3
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
   segments. */
#define MEMP_NUM_TCP_SEG        4 //changed was 16
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
   timeouts. */
#define MEMP_NUM_SYS_TIMEOUT    2

/* The following four are used only with the sequential API and can be
   set to 0 if the application only will use the raw API. */
   
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
#define MEMP_NUM_NETBUF         2
/* MEMP_NUM_NETCONN: the number of struct netconns. */
#define MEMP_NUM_NETCONN        2               //changed was 10
/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
   communication between the TCP/IP stack and the sequential
   programs. */
#define MEMP_NUM_API_MSG        2 //changed was 16
/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
   for sequential API communication and incoming packets. Used in
   src/api/tcpip.c. */
#define MEMP_NUM_TCPIP_MSG      2 //changed was 16

/*----------- Dhcp Options ---------- */
#define DHCP_OPTIONS_LEN         68  //changed was 0 but if less than 68,
will cause a redefinition error in dhcp.h

/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE          5 //changed was 100

/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE       128





reply via email to

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