https://developer.garmin.com/connect-iq/core-topics/backgrounding/
The documentation says:
The Connect IQ compiler allows you to select what code is necessary for running in the background with the
:background
annotation. Only modules, classes, functions and member variables decorated with the:background
annotation will be compiled into your background service. This means you must decorate all related code with the annotation (including your Application class).
But according to the following thread, global variables are always included in the background process:
Also, the docs don't mention a couple of edge cases:
1) If the :background annotation is not used at all, the entire application is loaded into the background, with a compiler warning
e.g. "The 'Background' permission was enabled but no source code was annotated. The entire application will be loaded as a background process."
2) If the :background annotation is used, but not on the app entry point / AppBase-derived class, the entry point is implicitly added to the background process, with a warning
e.g. "The entry point '$.SimpleDataFieldApp' was implicitly added to the background process since the app contains declarations annotated with (:background)."