title: C# Application performance deterioration due to garbage collection?
body: <p>My application's performance deteriorate as it continues to run through the day.</p>
  
  <p>I suspect it is garbage collector, how can I verify this?
  Is there a way to find out which object/function is causing garbage collection overhead?</p>
  
  <p>Is there a way to manually perform garbage collection programatically to clear memory of leakages?</p>
  
  <p>Thanks,</p>
  
  <p><strong>edit</strong> 
  On one end of the application it receives call back from a unmanaged api to accept data, processes it and then send messages out of socket on the second end. From the second end it then gets back follow up data on the messages it sent out.
  The application opens 5-6 sockets to send and receive data from the second end.
  It constantly logs lots of data to windows file system on a separate thread.</p>
  
  <p>My measurements include timestamping (queryperformance counter) just before I send data out and the timestampinga again when I receive the followup from another process back on the socket.
  I noticed out of multiple sockets I open, the performance deterioration is happening on one socket connection only.</p>
  
  <p>The processing between the timestamping and sending.receiving data over socket includes iterating through 2 arraylist that has no more than 5-6 objects and couple of callbacks.</p>
  
  <p>The memory usage from Task MAnager window does not go up considerably. From 96MB to 100MB after 6-7 hours run.</p>
  
  <p>Following are some observations from running perfmon.</p>
  
  <p>"finanlization survivors" and "promoted finalization memory from Gen 0" gradually increase with time</p>
  
  <p>"Gen 0 collections" going from 1819 at the start to 6000 after 4 hours.
  "Gen 1 Collections" is 10%-12% of Gen 0 collection and "Gen 2 collection" is 1% or less. COnsidering Gen 0 collection numbers are cumulative, it is probably not abig concern.</p>
  
  <p>GC handles" went up from 850ish to 4000. </p>