Garbage collection in

Posted on 2006-05-29
Last Modified: 2010-04-16
Hello Experts,
I develope c# program for windows mobil 2003 second edition.
The program syncronize with the server through gprs every 2 seconds and check for the new updates ( It is for a company who do deliverings ).
My problem is when i launch the program, the first 5 or 10 minutes it is working fine and after that it start geting slow and slow.
I know that garbage collection in C# is handled by .NET framwork and we do not have to do anything special.

Then what could be the reason tha program gets slow after a while.

can anyone give me a suggestion.

Thanks in advance and hope to hear.
Question by:Ludo_Dirckx
    LVL 11

    Accepted Solution

    may be you have some lists that keep growing... (you only add to that list) and iterating through them will take an increasing amount of time ...

    as for the garbage collector.
    you can force it to collect using gc.collect or gc.Collect(<generation>) and then wait for it to finish using gc.WaitForPendingFinalizers

    but the garbage collector will not free your objects if you keep a reference to them somewhere.


    Author Comment

    Hi Agarici,
    Thanks for the quick reply.
    I will check the code once again. There is only one place i can really say, that when i read an xml message through XmlTextReader and read it in a dataset and write the data to the local database. After i finishg this i clear the dataset like ds.Clear();

    Is there something wrong about this way of doing it ?

    Because every 2 minutes it will read the data to the dataset.

    hope to hear.
    LVL 11

    Expert Comment

    the xml is refreshed every 2 minutes?
    if yes, the new data is apended or it contains only the new data?


    Author Comment

    it is not appand,
    I read every time new data by the code bellow

    string connectString="";
    XmlTextReader reader = new XmlTextReader (connectString);



    LVL 11

    Expert Comment

    so, you solve it? what was the problem?

    Author Comment

    Hi Agarici,
    Sorry for the late reply.
    I just put the forc garbage collection as you said earlier when it does the sync for every 2 min.
    It was not bad because i can say the program blocks less that before.
    At this moment it is not bad.

    thanks for the help and mails.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now