Program vs. Variable Memory
When PLC projects are first designed, the specs must state the memory capacity, reserving the proper space for fixed programs and volatile variables needed for the application.
As we discussed in a previous chapter of this textbook, a PLC’s memory is divided into permanent and volatile types of storage. As we continue discussing the organization of PLC programs and data types, it’s important to revisit the memory structure so we can select the right PLC for each purpose. Datasheets list program and variable memory capacities for PLCs, but we never see any specs for more common types of memory, such as hard drives or RAM. Because of this, it is important to clarify the concept of memory as it relates to a PLC.
Program Memory
The program memory contains the instructions to be executed, such as ladder diagrams or structured text routines. It includes instructions in multiple locations: the main routines, any subroutines, custom function blocks and instructions, electronic datasheets of connected devices, and even comments and hardware configurations that may not feel like part of the program itself.
Think about it this way: most of us have connected to a PLC and chosen either to upload the current PLC project or to download the PC project. When we upload a project, it’s sent from the PLC to the laptop. All of that information existed on the PLC, and because it was retained through many power cycles, it must have been stored in a non-volatile memory region.
How Much Memory is Required?
How much program memory could be considered “enough” for a project? Unfortunately, the answer is far from simple. There are many recommendations according to users and manufacturers. The best ones mix approximations with prudence, assuming it is far less expensive to buy an oversized PLC than to replace the entire system shortly after commissioning. PLC memory can range from a few hundred KB (for older PLCs) to tens of MB for newer models. Don’t expect to find PLCs with GB or TB of storage, as one would on a modern PC.

Figure 8.2. At the time of writing (mid-2026), this is the most recent controller in this PLC line, with 80 MB of user memory.
A commonly quoted rule of thumb is to estimate about 5 words of memory per discrete I/O device (each word is 2x bytes) and 20 words per analog device (here’s an example source from AutomationDirect). This accounts for addresses and the use of instructions/math related to each device. A better estimate can be generated after the program is completed by using tools in the IDE or by saving the entire project to a folder on the PC and verifying its size.
It’s a good practice to purchase a PLC with at least 50% more available memory than the project requires. This accounts for future expansion, data logging, and other unpredictable changes.
Online and Offline Editing
Program memory cannot be changed while the PLC is running and executing instructions. Even when we can perform online editing, we must still pause the PLC's execution, send the program changes, and then resume execution of the new program. There are varying degrees of online editability, depending on the PLC and/or the software:
- No ability to edit online. We may be able to monitor variable and tag values, but we must go offline with the controller before attempting to make any changes to the program. We can either monitor values or edit the program, but not both.
- Editing variable values in real-time. In most PLCs, variables can be updated while the PLC is running. There are a few exceptions, like sensor values (we can’t edit those from the laptop) and output values (those are driven by the program, not the user). Aside from updating these values, we still must go offline before editing a rung or text lines.
- Online editing of the program. This simply means that we can edit the program in the IDE on the laptop while we are currently online with the PLC. We must still halt program execution before downloading the new program. The benefit of this method is that we can monitor the live program as we actively change it. However, once the edited program is downloaded to the controller, the old program is overwritten in its entirety.
Volatile Memory (Variables)
We also need to briefly discuss volatile memory (also called variables), which is not retained when power is lost. Variables in a PLC are treated slightly differently from those in typical computer programming environments.
In a typical computer program, global and local variables are declared and often initialized when the program is first executed. A declaration defines the name and type of each variable, and this is the function of the tag listing. No variable can be used in a program unless it is declared, but initialization, on the other hand, is optional.

Figure 8.3. These variables indicate the type of data and whether an initialized value is present (note that I/O tags cannot be initialized; they are determined by the real-world state before the first logic scan).
Initializing means setting a variable's value so it is guaranteed to hold that value until otherwise commanded. As an example of why this may be important, imagine a race timer. When the runners start, a “start” button is pressed, the value is set to zero, and counting begins. When the race ends, the “stop” button is pressed. But at the beginning, even before that first press of the start button, shouldn’t the display already read 0:00? It would be very confusing if the timer reads a random value when it first powers up.
After this example, we may wonder under what conditions initialization might be unnecessary. If the value will be overwritten by some calculation or by a real-world event before it’s ever seen or used, then maybe we don’t need to waste resources in setting that initial value; it simply won’t matter. I/O tags do not need to be initialized because the very first thing that happens in the scan cycle is to obtain new values. So the first consideration is this: if it doesn’t need to be initialized, don’t worry about it.
The second consideration is safety-related functions. Imagine a large hydraulic cylinder holding up a fixture. If, when the controller power supply flickers for a moment, the hydraulic cylinder valve defaults to a different position, that fixture might slam closed. Imagine how dangerous this would be for any technician operating nearby. For these safety functions, the values of variables at start-up should either retain the state prior to power loss or be initialized to a known “safe” state that reduces risk to anyone or any nearby objects.
Retentive Tags
All PLCs understand the concept of retentive tags. These are tags that retain their value during power losses. However, not all PLCs treat tags the same way.
Some PLC brands (notably Rockwell/Allen-Bradley) make all tags retentive by default. If power is turned off while a memory bit is set to true, it will remain true at the next power-up. Many other PLC brands limit the default retentive status to I/O tags only. If an output coil is energized in a conditional subroutine and then the PLC undergoes a power cycle, that coil will remain energized until told otherwise.

Figure 8.4. In this PLC, the tag listing displays the memory retention status of each variable. Consecutive blocks of memory, timers, and counters can be set as retentive.
For tags that exist only in the PLC’s memory, the default may be retentive or non-retentive, depending on the brand of PLC. Regardless of the default, memory tag settings always allow the programmer to check a box designating the tag as retentive or non-retentive. Further, if the tag is designated as non-retentive, a starting (initialization) value can also be assigned in these settings. In most cases, the default value of 0 is the best choice for initializing memory variables.
Now that we understand the types of memory, let’s break down the structure of projects and exactly how they are arranged and executed.