Core Memory

TwinCAT (3.1.4026 and 3.1.4024) enables real-time tasks to dynamically allocate memory within the real-time context. Since real-time tasks cannot allocate memory blocks directly from the operating system, TwinCAT offers various memory pools. These pools are memory blocks allocated in advance by the operating system. These memory blocks are pinned to the physical memory to avoid paging when accessing within the real-time context.

As already described in the chapter Settings tab, there are several memory pools for TwinCAT. These are:

Executable RT Memory

Executable real-time memory, this is required by the TwinCAT system and is not directly available to the user

Global RT Memory

Global real-time memory for memory allocations of TwinCAT modules (PLC and C++) in real-time context

Core Memory <n>

Real-time memory for memory allocations of the <n>th real-time core

Global ADS Memory

Data memory for ADS communication. Allocations for ADS messages between the TwinCAT components are allocated from this memory.

Tc/OS Memory

Memory pool of the Usermode runtime: allocation takes place when a Usermode runtime is started. When using a Usermode runtime, the other memory pools are served from this memory pool.

The size of the Global RT Memory can be set for each project via the Router Memory option in the TwinCAT 3 engineering environment. Since TwinCAT version 3.1.4026, the data memory for ADS messages has been separated from the "router memory" and is available as an independent global ADS memory. The size of the global ADS memory is determined from the size of the global RT memory and corresponds to 25% of its size, up to a maximum of 32 MB.

TwinCAT version 3.1.4026 also introduced another memory pool, the Core Memory. The Core Memory provides a dedicated pool for real-time for each individual real-time core. If the Core Memory is configured for a real-time core, an attempt is first made to provide the requested memory from this memory pool. If this is not sufficient, the memory from the global real-time memory is used.

The Core Memory thus allows parallel memory allocations from different cores to be processed in parallel and independently of each other. To access the global real-time memory, parallel memory allocations from different cores must be processed sequentially. This can lead to waiting times for many memory allocations within a real-time cycle and is therefore a performance bottleneck, e.g. in Vision applications.