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 6212257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:29:02+00:00 2026-05-24T06:29:02+00:00

I believe I have memory leak with some of my code that uses the

  • 0

I believe I have memory leak with some of my code that uses the XmlDocument class.

My program runs on a Windows 6.1.4 device (C#) and reads from a database on another server to see if any programs installed on the device need to be uninstalled and then reads from an XmlDocument to get the names of the programs that are uninstallable. The program then matches the lists and uninstalls accordingly, if necessary. This process is looped infinitely and runs in the background but what I’m noticing is that the memory creeps up slowly over time and the program eventually catches an OutOfMemoryException.

If I comment out everything and do nothing in the loop, the memory stays right around 2MB consistantly. If I leave everything but the following code commented out then the memory usage goes up .05 megabytes every minute or so continuously. Those results are with having the loop sleep for 1 second. The regular sleep speed is about 10 minutes. Any thoughts as to what could be causing the leak and if it has anything to do with the XmlDocument class?

foreach (string programName in uninstallPrograms)
{
    XmlDocument xmlDoc1 = new XmlDocument();
    xmlDoc1.LoadXml("<wap-provisioningdoc>" +
          "  <characteristic type=\"UnInstall\">" +
          "    <characteristic type=\"" + programName + "\">" +
          "     <parm name=\"uninstall\" value=\"1\"/>" +
          "    </characteristic>" +
          "  </characteristic>" +
          "</wap-provisioningdoc>");

    xmlDoc1 = ConfigurationManager.ProcessConfiguration(xmlDoc1, true);

    cmdStr += "DELETE FROM DEVICE_APPS WHERE ID = " + deviceAppIDList[count++] + "; ";

    xmlDoc1 = null;
}

// Check for pre-installed apps to uninstall
count = 0;

XmlDocument xmlDoc2 = new XmlDocument();

xmlDoc2.LoadXml("<wap-provisioningdoc><characteristic-query type=\"UnInstall\"/>" +
        "</wap-provisioningdoc>");

/**** The line below seems to be the cause of the memory leak ****/
//xmlDoc2 = ConfigurationManager.ProcessConfiguration(xmlDoc2, true);

XmlNodeList xmlNodeList = xmlDoc2.SelectNodes("wap-provisioningdoc/" +
        "characteristic[@type='UnInstall']/characteristic/@type");

xmlDoc2 = null;

cmdStr does eventually get used and is set to string.Empty at the end of the loop. At first I had didn’t have xmlDoc = null; in my code but it didn’t help either way. I’ve tried adding GC.Collect(); at the end of my loop and that seemed to help slow down the leak but it doesn’t fix it entirely. Plus I’ve read it’s not good practice to use it anyway.

Edit: So it seems to be the ConfigurationManager line that I commented out in my code above that has the memory leak. As soon as I comment out that line of code the memory leak stops. It starts back up when I uncomment this line. Is there something I need to do after making the call to ProcessConfiguration to release the memory?

Also, I am using the Microsoft.WindowsMobile.Configuration namespace for ConfigurationManager runtime version 1.1.4322 since System.Configuration does not exist in CF.

  • 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-05-24T06:29:04+00:00Added an answer on May 24, 2026 at 6:29 am

    Looks like the answer to this is to do it natively using DMProcessConfigXML(). Using this method does not cause a memory leak. So there must be something within the wrapper that is not releasing its resources properly.

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

Sidebar

Related Questions

Hy all, I believe that the following piece of code is generating memory leak?
I have been lead to believe that it is possible to pass a class
I have a Spring application that I believe has some bottlenecks, so I'd like
I have a program that accepts data from a socket, does some quality control
I believe I have a double delete and some memory corruption happening somehow in
I believe I have a potential threading issue. I have a user control that
I have a memory leak, and I guess it's caused by a wrong usage
I have windows application I wrote. I installed it on virtual server (vmware) that
Recently someone on Stack Overflow told me that the code below does not leak,
I have a misbehaving application that seems to leak. After a brief profiler investigation,

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.