mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
415 stars 118 forks source link

RAM usage improvement? #34

Closed mrdc closed 4 years ago

mrdc commented 4 years ago

Hello,

I'm using the Firebase library in my project on ESP32 Wroom, it doesn't have additional PSRAM, so there is not too much free RAM to use. What I've noticed is that my ESP32 Free Heap is 51292 after boot. I've compared Free Heap to the library IOXhop_FirebaseESP32 which gives me ~94700 after boot with the same code as used with your library. Do you think there is space for RAM usage improvement?

mobizt commented 4 years ago

It's strange and unbelievable. For example if you use two FirebaseData objects, the free heap is about 160-170k. Something wrong with your code? You should share your code.

mrdc commented 4 years ago

I'm using BLE - it uses a lot of RAM. Will test without BLE.

mobizt commented 4 years ago

You should not use BLE together with WiFi because it uses the same radio. You need to disable BLE and reboot to use WiFi only to get more free heap.

mrdc commented 4 years ago

BTW it's possible to use at the same time even if it uses the same radio.

mobizt commented 4 years ago

No, you will get unreliable WiFi and leads to SSL/TLS connection failed because mbedTLS uses 100k ram or more for SSL connection

mrdc commented 4 years ago

I know about mbed memory usage. In may case it works OK.

mobizt commented 4 years ago

Are you sure for SSL/TLS not just a none secure http?

mrdc commented 4 years ago

How can I check it? What I see is that ESP32 connects to 443 port.

mobizt commented 4 years ago

You can test to use WiFiClientSecure to connect to some server via ssl (use https in server url or host). It uses a lot of ram in SSL handshake and decrypt/encrypt exchanged data.

I'm not recommended to use both BLE and WiFi at the same time for high WiFi priority tasks as stream which it needs connection to stay alive.