You receive a System OutofMemory Exception when doing a Model Export in Dynamics AX

You receive a System OutofMemory Exception when doing a Model Export in Dynamics AX

I ran into this recently on an assignment and couldn’t find the documented fix anywhere. So, I thought that I would write it here to save someone troubleshooting.

What is a model?

Basically, this all the code and metadata within Dynamics AX – table names, column names, code classes, ect. When implementations are large enough, this can become a lot of information.

Why is a model export important?

At current, our Dynamics AX code migration strategy is different than traditional code migration strategies. We basically save(aka export) all of our current code from one environment and just completely overwrite all the code in some other environment with it. That makes it easy to do code migrations with several traditional architecture principles sacrificed. So, in lay terms, it is the way that you deploy customizations from one environment to the next (like dev to production).

What does this error mean?

What this really means is that your system ran out of RAM to carry out the model Export. It does not mean that your server is out of RAM – only that it was not able to allocate enough RAM to the process doing the model export.

Who is vulnerable to this?

The current Import/Export modeling routines do not efficiently stream data. By streaming data, we break it out into chunks so that the data does not fully reside in the RAM of the server. So, for example, even though we have a 10GB file, we may end up with only 1 GB of information in the RAM at a time because we remove and add sections of the information as needed.

That isn’t possible with the way that our current model process executes as one long transaction(different topic).

Thus, places with existing low ram on the server, modified powershell code that uses 32-bit processes, or very large models – anything that can introduce a RAM problem essentially.

How to fix it?

In my case, I was able to fix it by simply running powershell as a 64 Bit process. If you see my post on Sarbanes-Oxley and setting up the security tool, you will see a step where I ran the Powershell through an x86 GUI ( Don’t do that if you get this error. Run it through a 64-bit process by choosing the GUI without the x86. .

While that fix was simple, not being able to use enough RAM could still be a problem with an entire multitude of fixes. The key is to understand the cause of the problem, and I hope that this helps anyone who encounters this problem.