Yes! Do not afraid to call GC.Collect() anymore

you can see a bunch of post writing that Garbage Collector on .net framework is smart enough so you should not handle it your self

the fact is, the correct statement should be

if you know the right time to call GC.Collect(), please call it
~me šŸ˜›

i realize it when developing for wp7, limited memory makes you watch the memory usage
on desktop, when memory full, it can use hard diskĀ but on phoneĀ memory usage more than certain threshold, bam ! your apps killed
therefore havingĀ your appsĀ small footprint memory is good, either on phone, desktop, so yesĀ if you know the right time to callĀ GC.Collect(), call it!

but what actually the danger stuff that people talking about?

Weak Reference
http://msdn.microsoft.com/en-us/library/system.weakreference.aspx

Telling garbage collector on what variablesĀ having weakĀ reference is the hard part, it’s so unmanaged…
~me šŸ˜›

When you tellĀ a variable is a weak reference, yourĀ variable can gone collected by garbage collector on unknown time
that’s the real danger!

but do not avoid it! it’s dangerous indeed, it just sometimes you must do it.

Advertisements