Garbage collection in c#.net

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.
Ludo_DirckxAsked:
Who is Participating?
 
AgariciCommented:
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.

hth,
A.
0
 
Ludo_DirckxAuthor Commented:
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.
0
 
AgariciCommented:
the xml is refreshed every 2 minutes?
if yes, the new data is apended or it contains only the new data?

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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


string connectString="http://domain.com/fmi/xsl/eks/listLever.xsl?&status7_syncro_PDA=2";
XmlTextReader reader = new XmlTextReader (connectString);

try

{

ds.ReadXml(reader);
0
 
AgariciCommented:
so, you solve it? what was the problem?
0
 
Ludo_DirckxAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.