Greetings ,
how can I know , when GC is raised or activated ??
thanx a lot
Printable View
Greetings ,
how can I know , when GC is raised or activated ??
thanx a lot
Well I don't think the Garbage Collector itself fires any events, but when an object is going through GC it calls the Finalize() method.
If there is no way of knowing maybe you better control it by forcing the Garbage Collctions yourself.
But The finalize methods as Wyrd stated probably could be used as they don't fire until the object is collected.
guys
I believe that Finalize Method used to do specific job before releasing the object.I dunno if I'm wrong but ...
There sould be a way around forcing GC to fire as need!!!
You better have a pretty darn good reason to fire the GC from your code. Try using GC.Collect() in your code. It defintely hinders performance. Also, the Finalize() method is called right before the GC destroys the object. You should implement the Finalize() method in your class if you have unmanaged resources that need to be cleaned up. As you all probably know, the GC is nondeterministic. There is no way of knowing when the GC will come around and pick up the garbage. You should not have code that relies on this.
simply
in my WebBrowser project , I've created a lot of objects so I need to free the memory when these objects aren't needed so that doesn't affect the performance.
I guess MS didn't create GC at all:D
The GC automatically frees up memory for you. There is no need to do it yourself.
Also, I could be wrong on this, but I believe that even calling GC.Collect() won't necessarily free up all unused memory. You'll need to also call the GC.WaitForPendingFinalizers() to make sure everything marked for GC is cleaned up before continuing. But as Lethal pointed out, this hurts performance and is bad, bad, bad.
Okey wyrd, what is worst is the existance of the unused objects in momery , I know that GC is automatically does that but I really need to free up the mem .I will not wait till the system halt.:rolleyes:
Check out this article. Maybe it will help clear some things up for you..
http://www.gotdotnet.com/team/librar...anagement.aspx
Frustrating:( :(
anyways thanx Lethal for the damn article....crying
**** Microsoft