|
参考老衲五木的博客http://blog.sina.com.cn/s/blog_62a85b950101am5d.html
-
如何更改lwip的最大socket数. 修改lwipopts.h中的 MEMP_NUM_NETCONN 值
/**
*MEMP_NUM_NETCONN: the number of struct netconns.
*(only needed if you use the sequential API, like api_lib.c)
*/
#ifndef MEMP_NUM_NETCONN
#define MEMP_NUM_NETCONN (13)// zbdchange 13 <- 8
#endif
-
如何精简lwip消耗的内存.
修改lwipopts.h中的
/**
* MEM_SIZE:the size of the heap memory. If the application will send
* alot of data that needs to be copied, this should be set high.
*/
#ifndef MEM_SIZE
#define MEM_SIZE (48*1024)// zbdchanged <-120
#endif
/**
*TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default,
*you might want to increase this.)
*For the receive side, this MSS is advertised to the remote side
*when opening a connection. For the transmit size, this MSS sets
* anupper limit on the MSS advertised by the remote host.
*/
#ifndef TCP_MSS
#define TCP_MSS 1400 // 536
#endif
/**
*MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM andPBUF_REF).
* Ifthe application sends a lot of data out of ROM (or other static memory),
*this should be set high.
*/
#ifndef MEMP_NUM_PBUF
#define MEMP_NUM_PBUF 32//16
#endif
/**
*PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
*/
#ifndef PBUF_POOL_SIZE
#define PBUF_POOL_SIZE (16*3)// zbdchange 16*3 <-16*5 表示缓存池的数量
#endif
Lwip消耗的主要内存是PBUF_POOL_SIZE*TCP_MSS
所以修改这两个值可以很大的减少内存.
|