Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:38:13+00:00 2026-06-11T21:38:13+00:00

I have a function that will will generate a dataset and create an xml

  • 0

I have a function that will will generate a dataset and create an xml file from it. The function is working perfectly. The problem is that I will get an “Out of memory” error after running the report several times. When I test the report I found that the memory usage will increase a lot when it reachs this XmlDocument command.
I used the GC but no use, any suggestions?

if (ddlDir.SelectedItem != null && ddlSec.SelectedItem != null)
{
    using (DataSet dsClosedKPICalls = GetReportData())
    {
        dsClosedKPICalls.DataSetName = "ClosedKPICalls";
        foreach (DataTable table in dsClosedKPICalls.Tables)
        {
            table.TableName = "ServiceInfo";
        }
        XmlContent = dsClosedKPICalls.GetXml();
    }

    XmlDocument XML_Data = new XmlDocument();           // contains the resultant XML data

    XML_Data.LoadXml(XmlContent);
    XmlNodeList TablesList = XML_Data.SelectNodes("ClosedKPICalls/ServiceInfo");

    for (int i = 0; i < TablesList.Count; i++)
    {
        XmlDocument innerXML = new XmlDocument();

        using (DataSet dsTaskDetails = getSplitupRecords(TablesList.Item(i).SelectSingleNode("ServiceNo").InnerText))
        {
            dsTaskDetails.DataSetName = "TaskDetails";
            foreach (DataTable tbl in dsTaskDetails.Tables)
            {
                tbl.TableName = "RequestInfo";
            }

            innerXML.LoadXml(dsTaskDetails.GetXml());

            TablesList.Item(i).AppendChild(XML_Data.ImportNode(innerXML.SelectSingleNode("TaskDetails"), true));

            innerXML = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:38:14+00:00Added an answer on June 11, 2026 at 9:38 pm

    How large are your XML documents? Specifically are they larger than about 85K?

    The .Net framework uses something called the Large Object Heap (LOH) which will be used for allocations larger than ~85K. If your XML documents are larger than this then stuff (like strings) will probably get allocated in the LOH. The problem with the LOH is that it is not compacted, and so it is susceptible to memory fragmentation, which can in turn result in OutOfMemoryExceptions being thrown even when the process should normally be able to allocate that memory. This may be the cause of your problem.

    For solutions you can either try

    • Reducing the use of the LOH by trying to keep the size of your objects below 85K. This can be difficult to achieve depending on your application, however it may be possible to (for example) split up your large XML documents into many smaller documents.
    • Try targetting the .Net framework v4.5 and seeing if that helps. The .Net framework v4.5 includes improvements to the LOH that may help in this case.

    As an aside, your calls to GC.Collect and GC.WaitForPendingFinalizers are a bad idea, as this can artifically promote lower generation objects into higher generations and generally “mess with the garbage collector”. These calls will also almost certainly not help in this case. As a general rule you should steer well clear of manually invoking a garbage collection unless you know exactly what it is that you are doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that will parse some data coming in. My problem is
I currently have a function that will create X tasks of a function based
I have created a function that will return the string path from my DB.
I have problem with fancybox. I want to write a function that will run
I need to create a function that will generate 2 random numbers between x
Hello I have a jQuery function that will send to a php file some
I'm looking to create a reusable function that will generate a random key with
Hi I have a function that will generate a random string which works fine.
For my program I am trying to create a function that will generate an
I have a php function I wrote that will take a text file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.