Monday, April 20, 2015

Error executing code: Insufficient memory to run script. (objects with large buffer ex: xml reponse streams)

​If you see the error "Error executing code: Insufficient memory to run script"
This means that an object/variable within AX is trying to load something into a variable that exceeds the max buffer size for a variable.



When you see this error you have 2 options to fix the issue. 1. reprogram the large object to only load sections at a time. However the bad part about this is you cant just load the large objects in chunks and then combine them into 1  because when you combine them they also can not exceed the max limit. So you would need to grab part 1/4 and display/process. Then dispose of the object and get part 2/4 then dispose and get part 3/4 if you wanted to view 1/4 then you would need to dispose of 3/4 then reload part 1/4.



However you also have option 2 which is you can up the maxbuffersize for variables. This is done via the ax config file (.axc files) that the client loads. This should not be confused with the buffer size set on an AOS server that is normally 48KB. By default AX is set to allow 4mb for this variable buffer size property however in some instances doing the "partial load" doesn't make sense so you need to bump it. For instance when returning large XML data response streams you may need to up this so you can read the response in and then parse it.



If you wish to up the size of the maxbuffersize for variables within X++ the setting that needs to be added to the config file is

maxbuffersize,Text,125



where 125 is the size in MB of the new max buffer size. You can make it 0 which will allow it to be unlimited however that is highly not recommend.

You can also add the change via the registry however in 2012 R2 I did not have much luck getting the client to respect it.
 
Client Registry
Key name: [HKCU\Software\Microsoft\Dynamics\6.0\Configuration\]
Value name: maxbuffersize
Value type: REG_SZ
Value: 125

No comments:

Post a Comment