# Rltk\_wlan\_init() is using too much heap

**URL:** https://forum.amebaiot.com/t/rltk-wlan-init-is-using-too-much-heap/3813
**Category:** SDK
**Tags:** rtl872xd
**Created:** [February 13, 2025, 3:09am UTC](https://forum.amebaiot.com/t/rltk-wlan-init-is-using-too-much-heap/3813 "2025-02-13T03:09:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nethercap\_Dev](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nethercap_dev/32/2218_2.png) [@Nethercap\_Dev](https://forum.amebaiot.com/u/Nethercap_Dev)
#### Post date: [February 13, 2025, 3:09am UTC](https://forum.amebaiot.com/t/rltk-wlan-init-is-using-too-much-heap/3813/1 "2025-02-13T03:09:09Z")

</div>

rltk\_wlan\_init() in function wifi\_on is using too much heap, causing pbuf alloc failure and makes my web server to stop functioning. I put some diagnostic prints and here is the result :

Initializing WIFI …

before rltk\_wlan\_init :Free heap: 187296 bytes  
after rltk\_wlan\_init :Free heap: 127360 bytes  
before rltk\_wlan\_init :Free heap: 127360 bytes  
after rltk\_wlan\_init :Free heap: 81952 bytes  
before rltk\_wlan\_start:Free heap: 81952 bytes  
after rltk\_wlan\_start :Free heap: 68256 bytes  
before rltk\_wlan\_start:Free heap: 68256 bytes  
after rltk\_wlan\_start :Free heap: 68256 bytes

WIFI initialized

I assume rltk\_wlan\_init() and rltk\_wlan\_start() is called twice because i set the mode to AP\_STA, but still, ~105 KB just for initializing WiFi interface is seems too much. I there a way to decrease the heap usage?

I am using board definition version 3.1.7

---

<div class="post-metadata">

### Author: ![M-ichae-l](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/m-ichae-l/32/33_2.png) [@M-ichae-l](https://forum.amebaiot.com/u/M-ichae-l)
#### Post date: [February 17, 2025, 3:55am UTC](https://forum.amebaiot.com/t/rltk-wlan-init-is-using-too-much-heap/3813/2 "2025-02-17T03:55:54Z")

</div>

Could you try the early release V3.1.8 for this question?  
[https://github.com/Ameba-AIoT/ameba-arduino-d](https://github.com/Ameba-AIoT/ameba-arduino-d)

---

<div class="post-metadata">

### Author: ![Nethercap\_Dev](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/nethercap_dev/32/2218_2.png) [@Nethercap\_Dev](https://forum.amebaiot.com/u/Nethercap_Dev)
#### Post date: [March 3, 2025, 2:04am UTC](https://forum.amebaiot.com/t/rltk-wlan-init-is-using-too-much-heap/3813/3 "2025-03-03T02:04:01Z")

</div>

Unfortunately, it does not seem to do much.

Initializing WIFI …

before rltk\_wlan\_init 187296  
after rltk\_wlan\_init 127360  
before rltk\_wlan\_init 127360  
after rltk\_wlan\_init 81952  
before rltk\_wlan\_start 81952  
after rltk\_wlan\_start 68256  
before rltk\_wlan\_start 68256  
after rltk\_wlan\_start 68256

WIFI initialized
