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

  • Home
  • SEARCH
  • 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 8471243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:44:35+00:00 2026-06-10T16:44:35+00:00

In my program i write data to files if i am not able to

  • 0

In my program i write data to files if i am not able to connect to database and I have a separate thread that has timer which checks for connection availability after every 25 seconds and if it can connect it transfers the data from files to the main db and deletes the file.
the problem is i never stop this timer,can this lead to memory leaks?
if i just run my program and monitor the task manager i can see the memory usage increasing continuously if i disable the timer and then run my application then the memory is stable

    public BackgroundWorker()
    {
        _backgroundWorkerThread = new Thread(new ThreadStart(ThreadEntryPoint));
        _timer = new SWF.Timer();
        _timer.Tick += new EventHandler(_timer_Tick);
        _timer.Interval = 25 * 1000;
        _timer.Enabled = true;
    }

    void _timer_Tick(object sender, EventArgs e)
    {
        bool lanAvailabe = NetworkInterface.GetIsNetworkAvailable();
        if (lanAvailabe)
        {
            if (!GetListOfFiles())
            {
                return;
            }
        }
        else
            return;
    }

implementation of GetListofFiles()

    private bool GetListOfFiles()
    {
        string sourceDirectory = pathOfXmlFiles;
        if (!Directory.Exists(sourceDirectory))
        {
            return false;
        }
        var xmlFiles = Directory.GetFiles(sourceDirectory, "*.xml");
        if (!xmlFiles.Any())
        {
            return false;
        }
        foreach (var item in xmlFiles)
        {
            ReadXmlFile(item);
        }
        foreach (var item in xmlFiles)
        {
            if (_writtenToDb)
            {
                File.Delete(item);
            }
        }
        return true;
    }

method that reads xml files

    private void ReadXmlFile(string filename)
    {
        string[] patientInfo = new string[15];
        using (StreamReader sr = new StreamReader(filename, Encoding.Default))
        {
            String line;
            line = sr.ReadToEnd();
            if (line.IndexOf("<ID>") > 0)
            {
                patientInfo[0] = GetTagValue(line, "<ID>", "</ID>");
            }
            if (line.IndexOf("<PatientID>") > 0)
            {
                patientInfo[1] = GetTagValue(line, "<PatientID>", "</PatientID>");
            }
            if (line.IndexOf("<PatientName>") > 0)
            {
                patientInfo[2] = GetTagValue(line, "<PatientName>", "</PatientName>");
            }
            if (line.IndexOf("<Room>") > 0)
            {
                patientInfo[3] = GetTagValue(line, "<Room>", "</Room>");
            }

        }
        WriteToDb(patientInfo);
    }
  • 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-10T16:44:37+00:00Added an answer on June 10, 2026 at 4:44 pm

    if i just run my program and monitor the task manager i can see the memory usage increasing continuously

    Get a profiler. Task Manager is not a right tool. Can’t tell what is going on. It doesn’t mean that you have a leak. Maybe just GC doesn’t run cause there is enough space etc.

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

Sidebar

Related Questions

I need to write some input data files for a python program, and I
I need to write an I2C program which can write data to 32 bit
Say I wanted to write a program that would export calendar data so that
I am trying to write a simple program in C# that will read data
I have a foxpro database that we are trying to write to using MS
I have a possibly long running program that currently has 4 processes, but could
I have a program in which I want to be able to store certain
I have a class (in C++), call it Data , that has thousands of
I am using ofstream() to write data into file, i want the program to
I'm trying to read and write the data to the server using java program.

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.