GithubHelp home page GithubHelp logo

Comments (23)

h2zero avatar h2zero commented on May 22, 2024

NimBLEDevice::deinit(true) will delete all BLE objects and free the memory.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

NimBLEDevice::deinit(true) --- This is giving me error
NimBLEDevice::deinit() -- This is working fine but its not deleting HEAP of NimBLE.h Library Memory.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

@h2zero
I want the complete NimBLE functionality, including server, to be removed.
How can it be done ?
deinit() ---> Its the only way to do that .

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

deinit(true) is the best way to clear it all. I suspect you are using an older commit before that was added. Please update your library to the latest commit and try again.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

Ok...I'll try and update u
But Can we clear NimBLE library memory

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

But Can we clear NimBLE library memory

The deinit function will clear the library memory. Do you also want to clear the NimBLE stack memory? That can be done with the esp_bt_controller_mem_release() function, if you do this though you won't be able to re-init and use BLE again until reboot.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

Yess....NimBLE stack memory also
Got it !!!
Thanks again
I'll try and update

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

One more thing
ESP32 device, the NimBLE consumes around 80 K of RAM. Is this OK? I feel this is large amount of RAM, although it is less than Bluedriod.

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

NimBLE consumes around 80 K of RAM

That seems a little high for NimBLE, but this depends on what you're doing with it, how many attributes/data/connections etc.
For example, in some simple test applications I have 306kB of free heap before initializing, and 277kB after connection, so 39kB consumed.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

When I'm using BLE_UART service and the difference between the memory before and after initialisation is approx 16kB.
But When I'm using BLE and MQTT the difference is approx 110KB.
So, this diff is because of BLE used with MQTT or only MQTT

from nimble-arduino.

mm108 avatar mm108 commented on May 22, 2024

NimBLEDevice::deinit(true) --- This is giving me error
NimBLEDevice::deinit() -- This is working fine but its not deleting HEAP of NimBLE.h Library Memory.

@sanketa-54 I thought I'd leave a note for those who face the above problem. I faced a similar problem and then realized that I was using a slightly older version of the library and in that version deinit doesn't include the clearAll parameter. ::deinit(true) should just work fine with the latest version of NimBLE-Arduino.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

NimBLEDevice::deinit(true) --- This is giving me error
NimBLEDevice::deinit() -- This is working fine but its not deleting HEAP of NimBLE.h Library Memory.

@sanketa-54 I thought I'd leave a note for those who face the above problem. I faced a similar problem and then realized that I was using a slightly older version of the library and in that version deinit doesn't include the clearAll parameter. ::deinit(true) should just work fine with the latest version of NimBLE-Arduino.

@m-menon : Yes...Everyone should know latest commit.

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

When I'm using BLE_UART service and the difference between the memory before and after initialisation is approx 16kB.
But When I'm using BLE and MQTT the difference is approx 110KB.
So, this diff is because of BLE used with MQTT or only MQTT

@sanketa-54 Yes NimBLE is pretty light on it's own. When WiFi is used as well it causes the BT+Wifi coexist drivers to load + the WiFi driver and consumes quite a bit of heap. Sadly, there isn't much we can do about that here.

I've thought about creating a light weight WiFi library for basic connections / MQTT, that's only a thought for now.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

@h2zero :
It wolud be great if there's lighter WIfi library for basic functions.
One more thing If we use pSRAM for ESP32 then can we reduce NimBLE stack , library and functionalities heap ?

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

@sanketa-54

It wolud be great if there's lighter WIfi library for basic functions.

I'm not sure how much could be saved by doing this but it would be an interesting experiment. I won't be attempting it for a while though.

One more thing If we use pSRAM for ESP32 then can we reduce NimBLE stack , library and functionalities heap ?

NimBLE can be loaded into PSRAM, which will reduce the main heap use. Also if you need further reduction you can disable functionality you don't need (client / server etc..). All documented in nimconfig.h and here

from nimble-arduino.

Sanketa54 avatar Sanketa54 commented on May 22, 2024

@h2zero : Yes Thanku

from nimble-arduino.

Sanketa54 avatar Sanketa54 commented on May 22, 2024

@h2zero : Is there a way to see detailed layout of memory in ESP32 - arduino platform?
The below stuff we can see in idf platform
Total sizes:
DRAM .data size: 19104 bytes
DRAM .bss size: 49264 bytes
Used static DRAM: 68368 bytes ( 56212 available, 54.9% used)
Used static IRAM: 118037 bytes ( 13035 available, 90.1% used)
Flash code: 1079425 bytes
Flash rodata: 274040 bytes
Total image size:~1490606 bytes (.bin may be padded larger)

Please help me this...This will help me to add pSRAM efficiently

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

I don't know if there is any way for arduino to produce that data.

Only way I know is to use IDF and arduino as a component.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

@h2zero : I'm using psram with WROVER standalone module ( With Wifi , MQTT , Nimble ).
I have added this line in nimconfig.h as u suggested --- #define CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL 1
But only approx 10180 bytes is transferred to external RAM. ( that too after BLE init).

Please confirm the approach is correct and suggest more ways to reduce the memory.

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

Yes that looks correct. The NimBLE host is quite small.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

Great !!!
Can u suggest some more ways to transfer some memory to pSRAM.

from nimble-arduino.

h2zero avatar h2zero commented on May 22, 2024

I can't think of much else you could do. This is not something I have tried personally.

from nimble-arduino.

sanketa-54 avatar sanketa-54 commented on May 22, 2024

Thanks alot for the help.
Please let me know if you got anything.
I'll also post if got anything related to memory optimization

from nimble-arduino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.