|
-
Nov 29th, 2002, 06:24 PM
#1
Thread Starter
Sleep mode
Garbage Collector??
Greetings ,
how can I know , when GC is raised or activated ??
thanx a lot
-
Nov 30th, 2002, 03:20 AM
#2
Member
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.
-
Nov 30th, 2002, 07:04 AM
#3
Registered User
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.
-
Nov 30th, 2002, 10:09 AM
#4
Thread Starter
Sleep mode
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!!!
-
Nov 30th, 2002, 10:57 AM
#5
PowerPoster
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.
-
Nov 30th, 2002, 11:04 AM
#6
Thread Starter
Sleep mode
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
-
Nov 30th, 2002, 02:38 PM
#7
Member
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.
-
Nov 30th, 2002, 04:39 PM
#8
Thread Starter
Sleep mode
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.
-
Nov 30th, 2002, 05:55 PM
#9
PowerPoster
Check out this article. Maybe it will help clear some things up for you..
http://www.gotdotnet.com/team/librar...anagement.aspx
-
Nov 30th, 2002, 08:41 PM
#10
Thread Starter
Sleep mode
Frustrating
anyways thanx Lethal for the damn article....crying
**** Microsoft
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|