Global variables are kept always in memory whereas local variables are deleted after exiting from the routine where they were instantiated, however seems like not being the case in question. The most relevant screenshot you did not show, which is the compiling log, where it is possible to see all the compilation messages, such as unused variables. In addition, depending on the optimization schema it is plausible to assume that the compiler does not implement unused variables. Anyway, in your specific code above, not sure if this makes any difference, I would recommend to declare variables as volatile, just to check.