views:

60

answers:

2

This is mostly geared toward desktop application developers. How do I design a caching block which plays nicely with the GC? How do I tell the GC that I have just done a cache sweep and it is time to do a GC? How do I get an accurate measure of when it is time to do a cache sweep?

Are there any prebuilt caching schemes which I could borrow some ideas from?

+1  A: 

All you'll ever need to know (and then some):

http://msdn.microsoft.com/en-us/library/ee817645.aspx

Oh, and GC.Collect() forces a collect.

Stu
+1  A: 

While I obviously cannot speak to the specifics of your application, in most instances you should not tie your caching implementation to some perceived expectation for how the GC will work. As Stu mentions, calling GC.Collect() will force a collection (with overloads for a specific generation) but more often than not doing so will result in worse performance than just letting the GC manage itself.

If you do find (after doing some real performance testing) that you need to interact with the GC make sure you take into account the different types of GC's that the framework currently has (see here for more information).

akmad