title: Problem with large memory in a C# program
body: <p>I've a large amount of real time data need to be proceed as fast as possible.</p>
  
  <p>These data are coming from multi network connection threads.</p>
  
  <p>All network threads are passing the data to a shared function to proceed some translation and interpretation to the data revived, after that it saves the information into Concurrent Dictionary as object by object.</p>
  
  <p>The problem is I have an amount of objects might reach 150K stored on this dictionary. What happens is while fetching the object to update it takes much time rather than the accepted time.</p>
  
  <pre><code>public class MyObject
  {  
    System.Timers.Timer LostTimer = new System.Timers.Timer();
    public int ID;
    public DateTime UpdateTime;
  
    public  MyObject()
    {
      LostTimer.Interval = 20000;
      LostTimer.Elapsed+=TimerElapsedHandler(LostTimer_Elapsed);
      LostTimer.Enabled = true;
    }
  
    void LostTimer_Elapsed(object sender,EventArgs e)
    {
      if(UpdateTime &gt; DateTime.Now.AddSeconds(-20))
           Console.WriteLine(ID + " Lost...");
    }
  
  }
  
  public class MyClass
  {
    public MyClass(){}
  
    private ConcurrentDictionary&lt;int,MyObject&gt; Objects = new ConcurrentDictionary&lt;int,MyObject&gt;();
  
    void NetworkThread1DataRecived(eventArgs e)
    {
      Translate(e.Data);
    }
    void Translate(string[] data)
    {
     Task.Factory.StartNew(()=&gt;
     {
        Parallel.ForEach(data, s (()=&gt;
        {
           MyObject o = null;
           Objects.TryGet(int.Parse(s),out o)
           if(o == null)
           {       
               o = new MyObject();
               o.ID = int.Parse(s);
               o.UpdateTime = DateTime.Now;
  
               Objects.TryAdd(s,o);
           }
           else
           {
              o.UpdateTime = DateTime.Now;
           }
        });
     });
   }
  }
  </code></pre>
  
  <p>Now while working with more than 30K of objects it gives me objects lost. </p>
  
  <p>The logic is that I'm subtracting the object grace period from the current system time and compare it with the last update time for that object.
  Do you think that this type of thread safe array (Dictionary) can not handle this large amount of data and causes read./write access delays which causes object lost?</p>
  
  <p>Before I were using <code>List&lt;MyObject&gt;</code> and <code>Lock(Object){}</code> to handle the multi thread access to this shared memory, but it fails after 10K of objects. After changing it to dictionary (.Net build in thread safe list) it works well with 30K.</p>
  
  <p>My target is to reach 150K, can I reach it with this logic?</p>