Data Persistence Permalink

The lifespan of a variable and its data begins at the time when the variable is created and ends at the time when the variable is deleted and its memory is freed. The time when the variable is created, initialized, or instantiated depends on the declared scope. The time when the memory is freed usually depends on the scope as well. For example, the memory of global variables is freed by exiting the application.

They can retain data longer than usual. The following mechanisms in CODESYS are provided for this purpose.

Mechanisms for data retention

  • (A): ⮫ Persistent global variable list _cds_icon_persistent_variables_configuration.png with the ‎PERSISTENT RETAIN‎ keyword

    Persistent variables retain their values when the application is reloaded. Moreover, the values are restored after a download, warm start, or cold start.

  • (B): ⮫ Retain variables with the ‎RETAIN‎ keyword

    Retain variables retain their values after a warm start, but not after reloading the application, a download, or a cold start.

  • (C): ⮫ Variables of the Persistence Manager of the CODESYS Application Composer

    Variables of the Persistence Manager are stored in an external file.

  • (D): ⮫ Recipe variables

    Recipe variables and their values are stored in a recipe file.