This function block provides the possibility to dynamically allocate memory and to release it again. Integrated counters indicate the memory consumption and thus enable an overview of the already allocated memory.

It is entirely up to the user to decide whether an instance is used across the entire application or whether several individual instances are used for different program parts. With larger applications, the latter may be advantageous in the case of diagnosis. This function block is capable of multi-tasking and an instance can thus be used from various task contexts.

If the function block determines that not all of the allocated memory has already been released when shutting down the PLC, an error message is sent as an event to the TC3 Event Logger.



nAllocatedSize: indicates the current size in bytes of memory allocated with this function block instance.

nBufferCount: indicates the current size of buffer allocated with this function block instance.

nObjectCount: - future reserved -




This method dynamically allocates memory and returns a pointer to this memory block. If allocation fails, e.g. because no free memory is available, the method returns ZERO.

An indication is given next to the desired size in bytes as to whether the memory block should be zeroed.

    nSize    : UDINT;    // requested size in bytes
    bReset   : BOOL;     // zero the allocated memory    



This method releases previously allocated memory again. The memory block must be allocated with the same function block instance beforehand and the size of this memory block must be specified.

    p       : REFERENCE TO PVOID; // the given pointer is reset to zero after deletion
    nSize   : UDINT;


Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4024.7

IPC or CX (x86, x64, ARM)