i.MX-RT1170 Hello everybody,
After modifying the memory configuration of RT1176, I encountered a mempma11oc: out of memory in poo1 NETBUF error. I spent two months without finding the problem, please help me find the reason, thank you
Hi @linsy
Hope you are doing well.
I looked up key information about this example you provided and It seems not from NXP offical examples, below coments for your reference to debug, hopt it help you find the root cause.
1. Enlarge MEMP_NUM_NETBUF
// Depends on your runtime enviroment
if (memp_free(MEMP_NETBUF) < 10) { // 当剩余内存少于10个时
PRINTF("Increasing NETBUF pool size\n");
memp_increase(MEMP_NETBUF, 10); // 增加10个
}
2. Check for Memory Leaks
Ensure there are no memory leaks, especially in critical paths where memory is allocated frequently.
Add Memory Allocation Tracking
Add logging to track memory allocations and identify their locations.
void *netbuf = memp_malloc(MEMP_NETBUF);
if (netbuf == NULL) {
PRINTF("Out of memory allocating NETBUF\n");
} else {
PRINTF("Allocated NETBUF at %p\n", netbuf);
}
Check Release Conditions
Ensure that memory is released properly when it is no longer needed.
memp_free(MEMP_NETBUF, netbuf);
PRINTF("Freed NETBUF at %p\n", netbuf);
By adding these logs, you can trace where memory is allocated and ensure that it is released correctly. This will help identify any potential memory leaks in your code.