embedded
resource_error
ai_generated
true
lwIP:pbuf_alloc失败:PBUF_POOL耗尽,总计16,空闲0,最低0
lwIP: pbuf_alloc failed: PBUF_POOL exhausted, total=16, free=0, low=0
ID: embedded/lwip-pbuf-pool-exhaustion
82%修复率
86%置信度
1证据数
2024-08-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| lwIP 2.1.3 | active | — | — | — |
| lwIP 2.2.0 | active | — | — | — |
| STM32Cube_FW_H7_V1.11.0 | active | — | — | — |
根因分析
lwIP的PBUF_POOL内存池为空,因为所有缓冲区都在使用中,通常由于网络流量峰值、未处理数据包的内存泄漏或池大小配置不足引起。
English
The lwIP PBUF_POOL memory pool is empty because all buffers are in use, typically due to network traffic spikes, memory leaks from unprocessed packets, or insufficient pool size configuration.
官方文档
https://www.nongnu.org/lwip/2_1_x/group__pbuf.html解决方案
-
Increase PBUF_POOL_SIZE in lwipopts.h (e.g., from 16 to 32 or 64) to handle burst traffic, and reduce PBUF_POOL_BUFSIZE if packet sizes are small.
-
Add a check in the Ethernet ISR to drop packets if pool is low, preventing system lockup: `if (pbuf_alloc(PBUF_RAW, 0, PBUF_POOL) == NULL) { return ERR_MEM; }` -
Implement a periodic task to free orphaned pbufs by checking `lwip_stats.mem.used` and calling `tcpip_thread()` processing to flush queues.
无效尝试
常见但无效的做法:
-
80% 失败
Larger windows require more buffers; if the pool size isn't increased, exhaustion still occurs under load.
-
90% 失败
This shifts computation to CPU but doesn't affect buffer allocation; pool exhaustion persists.
-
95% 失败
ARP cache management doesn't free PBUF_POOL buffers; those are for packet data, not ARP entries.