Jump to content
  • Advertisement
Sign in to follow this  
shrek2

[.net] When does C#.Net perform garbage collection?

This topic is 3711 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I read that .net finds the optimal time to do garbage collection. When it does it, it'll freeze your program, do garbage collection, and the restart your program again. Does anyone know how .net determines the optimal garbage collection time?

Share this post


Link to post
Share on other sites
Advertisement
Whatever you read was wrong, or you read it wrong.

There are three types of GC that the .Net framework is capable of. The default one is concurrent with your application, and will only halt your threads if it absolutely must, in all other cases your application will continue running while the GC progresses. The other non-default client GC will freeze your threads while it collects. There is also a server GC.

The GC typically runs when you call new, as this is the best time that it can determine if the various generations are full and what level of a collection to perform (gen0, gen1, gen2).

You may wish to check out Maoni's blog for good information on the GC and how it works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!