Maximum open cursors in Dynamics AX

This article is to dispel a myth about the maximum open cursors setting in Microsoft Dynamics AX.

An important AOS change took place more than a year ago and awareness of it seems to be still quite low.

The "you have exceeded the limit for open cursors" error message was removed from AX2009 (and AX2012) in kernel 5.0.1500.3212 onwards - KB 2266595.

Yes it’s true! So now if you exceed the limit, you won't see any error. The full error was:

"Upper limit for open cursors has been exceeded (90) - use parameter openCursors or change the X++ code."

What used to happen is that when creating a new statement (for a query) in the AX kernel, it would check the open cursors parameter value, and if that session had that many statements in use then it would raise the event log error but continue and create the new statement anyway (by removing the oldest inactive ones to make space for the new one). The problem was that raising the error message itself actually leaked memory (!).

As you can imagine once you've exceeded the limit then the error code might be hit a LOT of times as every statement created after that point may cause it to be raised.

In AX2012 this was more important - as for X++ running as IL you don't know when the .NET garbage collector is actually going to dispose of objects - so statements that an AOS has cached might be hanging around for longer than you expect - and you could therefore hit the open cursors error all the time, just because they weren't being cleaned up at a predictable interval.

So I hear you asking, what does this mean? Good question!
It means that the open cursors setting is no longer something anyone should touch -
because it's only related to an internal mechanism of AOS, and nothing is visible of that now - if no error is raised you don't know if you're exceeding the limit. The field will be left in the configuration utility and it will still do something when you set it, but the effect cannot be monitored, as it's purely an internal kernel mechanism. Setting the value higher will cause increased memory consumption, as the cache is allocated once for each session, so keeping it as default is a good option.

This means anyone with open cursor errors in AX2009, just needs to update their kernel and it will go away, no need to attempt to change the value (it will cause memory problems) or troubleshoot their code, as the newer kernel will just handle it.


/Tariq Bell

Comments (0)

Skip to main content