IoT devices are coming with greater memory constrains and the IoTHub SDK has options to shrink its ROM and RAM footprint considerably when you invoke cmake with the correct flags. These are some tips to reduce the c sdk memory footprints on these devices.
To maximize memory usage you should only include the protocol that is needed. For constrained devices, we recommend using MQTT which provides the best balance between RAM/ROM usage and feature support. To enable the c-sdk to run with just the mqtt protocol you will need to run the following cmake command:
cmake -Duse_amqp=OFF -Duse_http=OFF <Path_to_cmake>
There is extensive logging throughout the SDK. Every message will be included in the SDK's RAM and ROM footprint. Removing logging will reduce the size of your application.
cmake -Duse_amqp=OFF -Duse_http=OFF -Dno_logging=ON <Path_to_cmake>
Upload to blob is an SDK feature used to send data to Azure Storage. If your application doesn't need this feature you can remove the files
cmake -Duse_amqp=OFF -Duse_http=OFF -Dno_logging=ON -Ddont_use_uploadtoblob=ON <Path_to_cmake>
The strip command is used to reduce the size of binaries on the linux systems. After you compile your application use strip to reduce the size of the final application.
strip -s <Path_to_executable>