Ask a questionAsk a question
 

AnswerMy application uses more and more memory every 5 minute

  • Tuesday, September 29, 2009 11:40 AMShemoPT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a small chat program. Basic function of the program is that it must connect to server, but if server is not responding he tries to reconnect to server every 25 second. I noised that when server is not responding my chat client is using more and more memory- starting from 4600 kb rises to 38000kb and than gives me an error and shutdowns.

    I am using timer to make application go to Form_load  every 25 second - memory rises. I tried to use application.restart method- memory is not rising but it every 25 second it minimizes everything that is working on PC(because the application restarted.)   


    how can I fix such memory rise??

Answers

All Replies

  • Tuesday, September 29, 2009 1:26 PMAndez Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi ShemoPT,

    How are you establishing comms between your server and client?
    Sounds like you are creating a new object each time you are trying to connect?  Could you ensure that the object is getting destroyed if connect is unsuccessful?  I use TCP sockets and not seen the issue.  And also remoting I've never noticed this.  Each time I create my proxy and try to connect I forcefully set it to nothing.

    Andez
    Andez
  • Monday, October 05, 2009 3:57 PMKarel ZikmundMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    In general - you have likely a memory leak in your application (you keep reference to memory you will never need again). Use a memory profiler or other memory leak detection tool for .NET to find out where do you leak the memory and fix it. Also check out internet resources for memory leak detection in .NET (e.g. How to detect and avoid memory and resource leaks in .NET applications).

    -Karel
  • Monday, November 02, 2009 11:39 PMFabrice MARGUERIEMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks Karel for the pointer to my article.
    Please note that it's now also available on MSDN .

    Fabrice
    LINQ in Action, the book [http://LinqInAction.net] - .NET pros and jobs [http://proagora.com]