Hi all,
I am currently transiting my project from memory heap to memory pool.
I have defined MEM_USE_POOLS and MEMP_USE_CUSTOM_POOLS to 1. Add lwippools.h as follows:
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(20, 256)
LWIP_MALLOC_MEMPOOL_END
Therefore, the memp_t will be as follows
typedef enum {
MEMP_RAW_PCB,
MEMP_UDP_PCB,
...
MEMP_MLD6_GROUP,
MEMP_PBUF,
MEMP_PBUF_POOL,
MEMP_POOL_256,
MEMP_MAX
} memp_t;
When lwip call pbuf_alloc in mld6_send as follows, mem_malloc will be called.
p = pbuf_alloc(PBUF_IP, sizeof(struct mld_header) + MLD6_HBH_HLEN, PBUF_RAM);
However, mem_malloc (under #elif MEM_USE_POOLS) in mem.c will allocate a MEMP_POOL_256 rather than MEMP_PBUF_POOL. Since MEMP_POOL_FIRST is MEMP_POOL_256 and the size is big enough.
I originally thought mem_malloc should allocate a MEMP_PBUF_POOL rather than MEMP_POOL_256. Is there anything I misunderstood? Is there a memory pool use example to reference or any material to discuss the memory pool usage?
Regards,
York