内存使用情况对比

[English]

此文档用来归纳不同芯片运行常用例程时的内存消耗情况。

常用例程剩余内存大小对比

请注意,以下测试结果没有经过任何内存优化,仅仅是直接运行 ESP-IDF 里的基础示例后获得的结果,如想查看内存优化后的结果,可参考 举例:ESP32-C3 内存优化前后的剩余内存大小对比

Application free memory Comparison

chip

Empty project

Station

Gatt_server

bleprph

provision(ble & Wi-Fi coexis)

thread

ESP32

366 K

230 K

205 K

201 K

140 K

not support

ESP32-C3

332 K

219 K

215 K

205 K

126 K

not support

ESP32-C3(ECO7)

332 K

230 K

225 K

214 K

136 K

not support

ESP32-C2

197 K

100 K

80 K

98 K

26 K

not support

ESP32-S3

392 K

273 K

276 K

267 K

189 K

not support

ESP32-C6

474 K

321 K

358 K

370 K

259 K

364 K

ESP32-H2

269 K

not support

150 K

166 K

not support

166 K

ESP32-C5

347 K

220 K

225 K

231 K

192 K

231 K

ESP32-P4

608 K

not support

not support

not support

not support

not support

ESP32-C61

265 K

136 K

150 K

159 K

80 K

not support

ESP32-S31

478 K

360 K

364 K

364 K

271 K

366 K

备注

如需进一步优化内存占用,请参考 ESP 内存占用优化

备注

  • ESP32-S31 在 master (commit 3a34711eacc41585481ba0e694dacb8d2d84e091) 上测试,使用各示例的默认 sdkconfig 配置。

  • 其他芯片在 release/v5.5 (commit 2e7a9174fcdc18f4c242aba5d9ff90644ea03cd2) 版本中测试,使用各示例的默认 sdkconfig 配置。

备注

在 ESP32-C3(ECO7) 中,无线应用有更多可用 RAM,Wi-Fi 相关增加 10 KB,BLE 增加 15 KB,共存模式增加 20 KB。 如需使用 ESP32-C3 (ECO7),请在 menuconfig 中使能以下配置: - Component config > Hardware Settings > Chip revision > Minimum Supported ESP32-C3 Revision > Rev 1.1 - Component config > SPI Flash driver > Use esp_flash implementation in ROM

举例:ESP32-C3 内存优化前后的剩余内存大小对比

Available free heap after optimization for ESP32-C3/ESP32-C2

example

内存优化前

内存优化后

Physical memory

400 K

400 K

Station

230 K

304 K

Station + 1TLS(MQTTS)

210 K

300 K

bleprph_wifi_coex

178 K

248 K

备注

  • ESP32-C3 数据在 ESP-IDF v5.2.2 中测试

  • got ip 事件后打印站点的空闲堆内存

  • Station + 1TLS(MQTTS) 的数据基于 ESP-IDF mqtt/ssl 示例,空闲堆内存在 MQTT_EVENT_DATA 事件后打印

  • ESP-IDF bleprph_wifi_coex 示例 测试中,nimble BLE 广播在 got ip 事件后启动,然后打印空闲堆内存