I clarify the concept of the RETAIN attribute of program variables. In accordance with IEC 61131 are given two types of starting a program in a PLC.
Warm restart, also known as Warm reboot, when the system is powered, the program execution starts at its beginning and RETAIN variables assume the value that they had when the system was shutdown.
Cold restart, after loading the program into the PLC or error conditions that caused a restart. The program execution starts at its beginning and RETAIN variables assume the value defined in the INIT field.
In each PLC there are usually more memory areas that while not having the attribute RETAIN are retentive, in our SlimLine CPU module for example, the memory area DB 100 starting at the 2048 up to its end (Offset 4095) is all retentive. So all the variables are allocated in this area retain their value on system power off and unlike the RETAIN variables also maintain their values after a program loads and/or system restart.