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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:27:43+00:00 2026-05-23T10:27:43+00:00

public class Worker { private Boolean Running = false; public Boolean Work = true;

  • 0
public class Worker
{
    private Boolean Running = false;
    public Boolean Work = true;
    private Process[] Processes;

    public event EventHandler<WorkerEventArgs> WorkerEvent;

    public virtual void OnWorkerEvent(String _Event)
    {
        if (WorkerEvent != null) WorkerEvent(this, new WorkerEventArgs(_Event));
    }

    public void Start()
    {
        while (Work)
        {
            Processes = Process.GetProcessesByName("iw4mp.dat");
            if (Processes.Count() >= 1)
            {
                if (!Running)
                {
                    OnWorkerEvent("Run");
                }
                Running = true;
                Thread.Sleep(2500);
            }
            else
            {
                if (Running)
                {
                    OnWorkerEvent("Exit");
                }
                Running = false;
                Thread.Sleep(2500);
            }
            foreach (var A in Processes)
            {
                A.Dispose();
            }
        }
    }
}

This class is leaking memory each 2.5 seconds (Yes, i monitored the memory usage with the Task Manager) when i call a ThreadStart with the Start() function. Any ideas on why is this happening…?

Basically, the Start() method should just poll if iw4mp.dat is running, even though it works… i have no idea why it keeps allocating memory each loop…

  • 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-23T10:27:44+00:00Added an answer on May 23, 2026 at 10:27 am

    It could be because you’re keeping the entire array. You dispose each Process object in the array at the end of the loop, but the array itself and all of its disposed (but not garbage collected) elements remain in memory. The garbage collector can come into action at arbitrary times, so if your system is not out of memory then it could be simply because the GC has not yet decided to collect.

    If you really want to force the collection, put this at the end of your loop:

    Processes = null;
    GC.Collect();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make multiple instances of this class. public class Worker { private
I have a co-worker that swears by //in a singleton Constants class public static
I have some code: public class Foo { private HttpClient httpClient; public Foo() {
I have a class called Worker public class Worker : BaseEntity { public virtual
public class MyClass { public int Age; public int ID; } public void MyMethod()
public class Test { public static void main(String[] args) { } } class Outer
public class Item { ... } public class Order { public List<Item> Items ...
public class Address { public string ZipCode {get; set;} } public class Customer {
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class CovariantTest { public A getObj() { return new A(); } public static

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.