# RTL8722 MINI Malloc failed

**URL:** https://forum.amebaiot.com/t/rtl8722-mini-malloc-failed/1131
**Category:** SDK
**Tags:** rtl872xd, evb-amb82, 中文
**Created:** [March 3, 2022, 2:48pm UTC](https://forum.amebaiot.com/t/rtl8722-mini-malloc-failed/1131 "2022-03-03T14:48:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Elton\_Jung](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/elton_jung/32/862_2.png) [@Elton\_Jung](https://forum.amebaiot.com/u/Elton_Jung)
#### Post date: [March 3, 2022, 2:48pm UTC](https://forum.amebaiot.com/t/rtl8722-mini-malloc-failed/1131/1 "2022-03-03T14:48:55Z")

</div>

String x\_data;  
for (i = 0; i \< 50000; i++){  
x\_data+=String(i);  
}  
請問我使用上面程式將0到5000記錄起來,結果發生以下問題  
[main\_task]Malloc failed [free heap size: 95424]

請問是否需要重新配置大一點的PSRAM呢?還是有其它的解決方向呢?

---

<div class="post-metadata">

### Author: ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)
#### Post date: [March 4, 2022, 2:15am UTC](https://forum.amebaiot.com/t/rtl8722-mini-malloc-failed/1131/2 "2022-03-04T02:15:01Z")

</div>

> [@Elton\_Jung](#):
>
> 95424

Heap還有93KB可以用，如果這樣還是不夠用，可以開啓PSRAM，但是請注意PSRAM的速度和功耗表現沒有SRAM好。

使用PSRAM的方法請看 [Application Note - Chapter 20.3](https://github.com/ambiot/ambd_sdk/blob/master/doc/AN0400%20Ameba-D%20Application%20Note.pdf)

---

<div class="post-metadata">

### Author: ![Elton\_Jung](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/elton_jung/32/862_2.png) [@Elton\_Jung](https://forum.amebaiot.com/u/Elton_Jung)
#### Post date: [March 4, 2022, 2:34pm UTC](https://forum.amebaiot.com/t/rtl8722-mini-malloc-failed/1131/3 "2022-03-04T14:34:53Z")

</div>

非常感謝,我研究一下PSRAM的用法及速度差異。
