Memory optimization configurations
There are multiple configuration options for optimizing memory consumption. In addition to the feature configurations for Client Lite, there are more options to reduce the code size and runtime memory.
This section lists the configurations you can define from your application to reduce memory footprint.
-
Build your client application with
nano-lib-cconfiguration because the client application is event driven and doesn't use threads. It is safe to usenano-lib-cas it is not thread-safe. This compilation configuration can produce a binary which saves around 25-30 kB flash size.-
To build and run this configuration successfully, make sure you have at least the following values in your application's
mbed_app.json:"mbed-client.enable-serialize-plaintext": false, "mbed-client.enable-deserialize-plaintext": false, "mbed-trace.enable": null, -
Build your application using this profile:
mbed compile -m NRF52840_DK -t GCC_ARM --profile profiles/pico_lte_size.jsonThe downside of this configuration is that you will not be able to see "plain-text" Resource values in Device Management Portal for human reading. The values are sent to Device Management in TLV format which can be easily understood by REST APIs for actual web service implementation.
-
-
If you are not planning to use the FOTA (update) feature, you can drop it at build time. In your
mbed_cloud_client_user_config.h://#define MBED_CLOUD_CLIENT_SUPPORT_UPDATEThis has an impact on both ROM and RAM.
-
Turn off more features required specifically by update. In the
mbed_app.json:"MBED_CLIENT_LWM2M_STRICT_MODE=1", "mbed-client.enable-auto-observation": false, "mbed-client.enable-publish-resource-value-in-reg-msg": false,
-
-
To measure the RAM consumption of your application, build it with the
-DMBED_HEAP_STATS_ENABLEDoption:mbed compile -m NRF52840_DK -t GCC_ARM -DMBED_HEAP_STATS_ENABLEDor
mbed compile -m NRF52840_DK -t GCC_ARM --profile profiles/pico_lte_size.json -DMBED_HEAP_STATS_ENABLED