ThingWorx Edge C SDK > Best Practices > Minimizing Code Footprint
Minimizing Code Footprint
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 determine what is disabled.
*/
#define TW_LEAN_AND_MEAN
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. Use #undef ENABLE_HTTP_PROXY_SUPPORT to disable the support for HTTP Proxies.
In addition, support for NTLM proxies adds ~45KB of code. Use #undef USE_NTLM_PROXY to disable this support.
File Transfer and Tunneling add ~15KB and 5KB respectively. Use #undef ENABLE_FILE_XFER and #undef ENABLE_TUNNELING to disable them.
Finally logging adds ~20KB of code. Logging can be disabled with macros partly by defining the log functions as empty. Here is an example:

#define TW_LOG(level, fmt, ...)
#define TW_LOG_HEX(msg, preamble, length)
#define TW_LOG_MSG(msg, preamble)
The twWindows.h and twLinux.h files provide examples of using TW_LEAN_AND_MEAN to minimize the code footprint.
Was this helpful?