Hi,
I believe that the memp module could be extended with a simple but
useful function that would print the current state of memory buffers.
The function could be enabled e.g. by defining
#ifndef MEMP_PRINT_DEBUG
#define MEMP_PRINT_DEBUG LWIP_DBG_ON
#endif
in opt.h, then declaring the function in memp.h:
#if MEMP_PRINT_DEBUG == 1
void memp_print(void);
#endif
and, finally, the function, which may be as simple as
#if MEMP_PRINT_DEBUG == 1
void memp_print()
{
int i;
for (i = 0; i < MEMP_MAX; i++) {
int count;
struct memp* m;
for (m = memp_tab[i], count = 0; m != NULL; m = m->next, count++)
;
LWIP_DEBUGF(MEMP_PRINT_DEBUG, ("Pool %s (size: %d): %d
block(s)\n", memp_desc[i], memp_bare_sizes[i], count));
}
}
#endif
Since memp_* variables in memp.c are private (static), which is
generally good, there is currently no access from outside of the file.
The effect of calling this function is such a nice set of messages:
21:07:50: Pool RAW_PCB (size: 28): 4 block(s)
21:07:50: Pool REASSDATA (size: 32): 5 block(s)
21:07:50: Pool ARP_QUEUE (size: 8): 30 block(s)
21:07:50: Pool PBUF_REF/ROM (size: 16): 16 block(s)
21:07:50: Pool PBUF_POOL (size: 1532): 16 block(s)
21:07:50: Pool MALLOC_64 (size: 64): 18 block(s)
21:07:50: Pool MALLOC_128 (size: 128): 20 block(s)
21:07:50: Pool MALLOC_512 (size: 512): 20 block(s)
21:07:50: Pool MALLOC_1600 (size: 1600): 20 block(s)
For us, this is currently the first place to look for memory problems
(insufficient memory due to leaks or logic errors, e.g., not calling
void ip_reass_tmr(void)).
Marek
------------------------------------------------------------------------
_______________________________________________
lwip-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-devel