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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Failed to allocate managed memory in Dynamics CRM using C#

(0) ShareShare
ReportReport
Posted on by 3,634

I've 1,072,369 contact records in Dynamics CRM. I needed to retrieve them and then manipulate. Now, while retrieving I faced following exception

Failed to allocate a managed memory buffer of 1073741824 bytes. The amount of available memory may be low.

I increased its time span to 10 minutes but no luck.

I am seeking your kind advise/help to resolve it. Following is my code snippet.

ColumnSet col = new ColumnSet();
col.AddColumns("new_name", "accountid", "contactid");

                //get Related Record
                QueryExpression qe = new QueryExpression
                {
                    EntityName = entity,
                    ColumnSet = col,
                    Criteria = new FilterExpression
                    {
                        Conditions = { 
                        new ConditionExpression("accountid",ConditionOperator.NotNull),
                        new ConditionExpression("statecode",ConditionOperator.Equal,0)
                    }
                    }
                };

                EntityCollection ec = sp.RetrieveMultiple(qe);


*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    There should be no reason to keep 1 000 000 records in memory while you manipulate them. Instead, I suggest you use paging with the QueryExpression to only return some (maybe 5 000) records at a time, then dispose of the records from memory, and retrieve the next page of data

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    I agree with david, for fetching record using paging,  Please refer the below URL :

    www.resultondemand.nl/.../0be338b9-dbb1-41b6-b313-c632e40d2af5.htm

  • Suggested answer
    Goncalo Almeida Profile Picture
    5 on at

    You can create pagination and records count and release the memory of the entity collection like this ec.Entities.Clear()

    The Dispose function is not available on the EntityCollection only on other components such as FileStreams for example.

    I was facing this issue and this solution helped me.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans