• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

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.
  • 3
  • 3
1 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.

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.
the xml is refreshed every 2 minutes?
if yes, the new data is apended or it contains only the new data?

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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);



so, you solve it? what was the problem?
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.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now