The everyday life of a Dynamics AX developer
When working with Dynamics AX, you can get the following error when opening a form:
Too many forms are currently open, close some forms and try again.
Restarting the client fixes it… for a while.
In my case the problem was that there were too many User objects in use by the Ax32.exe process. You can check how many are used in the Task Manager on the Processes tab. Click View – Select Columns… and select USER Objects from the list, then click OK. There is also a GDI Objects column that you can enable which shows a counter for a similar property (see: Object Categories).
When this is done, you should see a new column. The maximum number of allowed objects is 10000, so when the combined count reaches this point, you will get this error in AX.
When you see an application with a very high number of USER Objects, there is most likely a leak in that application. In my case ,that application was Ax32.exe. Each time I opened and closed the VendEditInvoice form, the number of USER Objects rose with more or less the number of controls on that form. After closing the form, the count didn’t drop, which it did do for other forms. This allowed me to identify that the problem was with the VendEditInvoice form.
This may have many causes, but in my case the cause was in the close method of the VendEditInvoice form. This method is overwritten but the code that was on there throws an error in some cases. A consequence of this was that super() was not executed, which caused the leak.
Conclusion: make sure you call super() on the close method of a form. When you have code that might throw an error, enclose it with a try/catch.