المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Force CG



C# Programming
05-14-2009, 12:00 AM
Hi All,

I'm just working on a WPF desktop database app and I may have a scenario that I think could benefit from the occasional forced garbage collection. The only reason I'm really venturing down this path is that my user base are pretty savvy types and memory is *always* at a premium.

When the app starts up it's consuming around 50Mb of RAM nothing to complain about. However, during certain searches on the database this memory usage can escalate to 150Mb+. Say search 1 returns 60,000 records from the Db and in this scenario the memory jumps to 150Mb and a short time later another seach might only return a few hundred samples. I'm seeing the memory still at around the 150Mb mark whereas I want this to be immediately reduced to reflect the required RAM needed to represent that smaller search result set.

Is it worth exploring a forced GC.Collect(). I've been doing plenty of reading and it seems like the message is a little mixed on this. Some people seem to use it regularly, some say never use it. Microsoft seem to say leave it up to the CG to decide, but as I illustrated above I want to free that RAM as quickly as possible.

Thanks,

Jammer
My Blog (http://jammer.biz/blog2/) | Article(s) (http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=4664921)