web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

System.OutOfMemoryException: Array dimensions exceeded supported range.

(0) ShareShare
ReportReport
Posted on by

I have a service which recursively creates a large array of objects. When i run this code in client, it works fine, but when i pass it off to the aos to execute as a batch using sysop framework i get this error

System.OutOfMemoryException: Array dimensions exceeded supported range.at System.Collections.Generic.List`1.set_Capacity(Int32 value) at System.Collections.Generic.List`1.EnsureCapacity(Int32 min) at System.Collections.Generic.List`1.Add(T item) 

at Microsoft.Dynamics.Ax.Xpp.Array.arrayValue(Int32 _index, Object _arg, Boolean isDefaultParam)

i have seen other examples of this in other .net languages. they say that you have to add a block to the app.config file to allow large arrays like this:

<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
</configuration>

but since i dont have access to ax's app.config, what can i do? this cannot be addressed another way.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,495 Most Valuable Professional on at
    RE: System.OutOfMemoryException: Array dimensions exceeded supported range.

    Your remark about gcAllowVeryLargeObjects suggests that you're trying to put more than two gigabytes of data to this single object. I would question whether your service is written in a reasonable way, because it looks like a waste of resources to me.

    Have you considered processing the data in smaller pieces or using a temporary table, to mention just two of possible approaches?

  • Community Member Profile Picture
    on at
    RE: System.OutOfMemoryException: Array dimensions exceeded supported range.

    My service performs an optimization which must first find all combinations of items from a list of items. We have accepted that it will be memory intensive. Consider this example as reference: https://www.geeksforgeeks.org/write-a-c-program-to-print-all-permutations-of-a-given-string/

    There is, as far as i know, no way to chunk this out into smaller bits since the recursion depends on the full scope of the tree being available in memory. 

    I typically agree that the first place to look is optimizing the code, but the nature of the problem requires a lot of memory to be available. So i have to return to the original request, which is to configure ax to allow the aos to run cil code with large arrays

    Thanks

    Steven

  • Martin Dráb Profile Picture
    236,495 Most Valuable Professional on at
    RE: System.OutOfMemoryException: Array dimensions exceeded supported range.

    Then you'll either have to fix the problem that you don't have access app.config, or you'll have to off-load this logic to a separate application.

    (I can't comment on whether the logic can be optimized or not, because I would need more details.)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans