Sunday, July 25, 2010

Setting max buffer size in Ax2009 for AIF

In Dynamics AX 2009 it can happen that a lengthy operation terminates with the following error message in the InfoLog:
Error executing code: Insufficient memory to run script.
A typical example that can result in this error message is when you are running the Reverse Engineering Tool of Dynamics AX 4.0 SP1. Another very common situation is when you are trying to process very large AIF messages with several thousand lines within AX or within an application that uses the Business Connector like the AX BizTalk Adapter.
With Dynamics AX 4.0 a new mechanism was introduced to limit the maximum amount of memory that can be allocated by variables (in X++ code) in a session. This maximum amount is set to 10 MB by default. For some operations like large AIF messages (that are stored in memory during processing) this is however not enough and so the operation is terminated when the maximum amount is reached.
The second part of the error message "Insufficient memory to run script." clearly indicates that this buffer was reached. It is possible to increase the buffer size in the windows registry by changing the following registery enteries


Key name: [HKEY_CURRENT_USER\Software\Microsoft\Dynamics\5.0\Configuration\(configuration name)] Value name: maxbuffersize Value type: REG_SZ Value: (Maximum amount of memory in MB or 0 for no limit)
For Dynamics AOS it is the following registry key Key name: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dynamics Server\5.0\(AOS instance)] Value name: maxbuffersize Value type: REG_SZ Value: (Maximum amount of memory in MB or 0 for no limit)
 This registry entry does, by default, not exist.
 It is recommended not to use value ‘0’ for ‘no limit’.
 After making changes to this registry value, ensure that the Dynamics service and/or client is restarted.

1 comment:

  1. If data's sent via the BizTalkAdapter/Business Connector, there's also the following value: [HKEY_LOCAL_MACHINE\Software\Microsoft\Dynamics\5.0\Configuration\(configuration name)]

    http://pvsax.wordpress.com/2010/08/06/aif-insufficient-memory-to-run-script/

    ReplyDelete