forwardFlatMessage Mode   Table of ContentFIX Messagingforward
Memory Consumption

The FIX Engine and FIX sessions allocate managed and unmanaged memory for internal structures during the work. The amount of allocated memory can affect the overall performance. The following articles describe how to optimize the amount of allocated memory.

Using Session.ScheduleShrinkToFit() Method

When a large message with many repeating groups is received, for example, SecurityList (y), the session allocates the memory for this message and each repeating group instance. This can increase memory consumption, especially when there are many such sessions. For performance reasons, this memory is not deallocated during the FIX connection lifetime because the deallocation and further allocation of new memory are expensive, so it cannot be performed after receiving each message. This memory is deallocated only after the Session.Logout() call. However, in some cases, it makes sense to have the ability to shrink this memory after receiving large messages. In such cases, ScheduleShrinkToFit() method can be used. This method will schedule the memory usage optimization. The session will perform the actual memory usage optimization after receiving and processing the next incoming message.

Optimizing FIX Dictionaries

When FIX Message is constructed, the space for all the fields, that are defined for the message, is allocated. The latest FIX specifications define a lot of fields for each message type. Even when most of the fields are not used, FIX Engine reserves the space for them, and this has a negative effect on FIX Engine's performance.

Editing dictionaries descriptions and excluding messages and fields (especially repeating groups), which are not used by the application, have direct influence onto the amount of allocated memory.

Using Optimal Values of Session.ResendingQueueSize Property

The ResendingQueueSize property specifies how many messages can be resent if a counterparty requests them. The session stores information about sent messages in the corresponding container. For performance reasons, this container allocates all necessary memory in advance when the session is constructed following the ResendingQueueSize property. Therefore, setting the ResendingQueueSize property to a large value can lead to unnecessary memory consumption. We recommend setting it to some limit value consistent with your system memory availability and resending requirements. If the resend requests functionality is not required, it is better to set it to zero.

See Also