ThingWorx Edge C SDK > Minimizing Code Footprint
Minimizing Code Footprint
To attempt to create the smallest possible code footprint, define TW_LEAN_AND_MEAN. Using TW_LEAN_AND_MEAN disables optional, resource-consuming entities, such as offline message storage, tunneling, and file transfer. The default behavior is to remove all logging from the system.
Another way to minimize code footprint is to disable the resource-consuming entities you do not require.
The following code example shows the definition for TW_LEAN_AND_MEAN:
/* Minimize Code Footprint */
Attempts to minimize the code footprint at the
expense of functionality. Check your OS port
header file to see what is disabled.
Tips for Minimizing Footprint and Maximizing Performance
The C SDK has several settings that can significantly impact code footprint and performance. For performance, key among them is disabling verbose logging mode. Verbose logging parses every message sent between your application and ThingWorx platform. While extremely valuable for debugging, it can have a significant impact on performance. It is recommended that you disable verbose logging by calling twLogger_SetIsVerbose(FALSE);
Several areas impact code footprint. Support for connecting through HTTP Proxies adds ~5KB to your final code size. If not needed, follow this example: Suppose you are connecting over a cellular connection. To disable the support for HTTP Proxies, use #undef ENABLE_HTTP_PROXY_SUPPORT.
In addition, support for NTLM proxies adds ~45KB of code. To disable this support, use #undef USE_NTLM_PROXY.
File Transfer and Tunneling add ~15KB and 5KB respectively. You can disable them, using #undef ENABLE_FILE_XFER and #undef ENABLE_TUNNELING.
Finally logging itself adds ~20KB of code. Logging can be disabled with macros in parts by defining the log functions as empty as follows:
#define TW_LOG(level, fmt, ...)
#define TW_LOG_HEX(msg, preamble, length)
#define TW_LOG_MSG(msg, preamble)
The twWindows.h or twLinux.h files provide examples of using TW_LEAN_AND_MEAN to minimize the code footprint.
The SteamSensor example, SteamSensorWithMinimalFootprint, in the /examples subdirectory of the installation shows how to set up an application that minimizes the footprint. When updating properties, you can minimize footprint by processing the property updates individually. To minimize the use of bandwidth, process the property updates all at once. The example shows both ways to update properties.