C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




To ChandraMohan and Sareesh


Posted Date: 12 Aug 2008      Total Responses: 2

Posted By: UmaShanker        Member Level: Silver     Points: 1


view this thread

http://dotnetspider.com/forum/164800-Difference-between-dispose-gc-collect.aspx

Why chandramohan and sareesh are copying the answer from sujaa...



Author: R.Sujaa 10 Aug 2008 Member Level: Silver Rating: Points: 6
differences

Finalize:

.NET Garbage collector does almost all clean up activity for your objects. But unmanaged
resources (ex: - Windows API created objects, File, Database connection objects, COM
objects etc) is outside the scope of .NET framework we have to explicitly clean our
resources. For these types of objects .NET framework provides Object.Finalize method
which can be overridden and clean up code for unmanaged resources can be put in this

Dispose:

This is the
best way we do clean our unallocated resources and yes not to forget we do not get the hit
of running the Garbage collector twice.

Collect:

System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if
situations arises.




Author: R.Sujaa 10 Aug 2008 Member Level: Silver Rating: Points: 5
The .NET object does this:

GC.Collect(GC.MaxGeneration);

GC.WaitForPendingFinalizers();

GC.Collect(GC.MaxGeneration);

With the 1.1 framework, the above approach was sufficient to cause any RCWs created for a .NET client that were no longer referenced explicitly in the .NET client code to be collected. That in turn allowed the RCWs to release my COM objects.

Now with 2.0, this no longer seems to work reliably.





Author: chandramohan 11 Aug 2008 Member Level: Gold Rating: Points: 6
Finalize:

.NET Garbage collector does almost all clean up activity for your objects. But unmanaged
resources (ex: - Windows API created objects, File, Database connection objects, COM
objects etc) is outside the scope of .NET framework we have to explicitly clean our
resources. For these types of objects .NET framework provides Object.Finalize method
which can be overridden and clean up code for unmanaged resources can be put in this

Dispose:

This is the
best way we do clean our unallocated resources and yes not to forget we do not get the hit
of running the Garbage collector twice.

Collect:

System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if
situations arises.




Author: Sareesh.V 11 Aug 2008 Member Level: Silver Rating: Points: 6
Finalize:

.NET Garbage collector does almost all clean up activity for your objects. But unmanaged
resources (ex: - Windows API created objects, File, Database connection objects, COM
objects etc) is outside the scope of .NET framework we have to explicitly clean our
resources. For these types of objects .NET framework provides Object.Finalize method
which can be overridden and clean up code for unmanaged resources can be put in this

Dispose:

This is the
best way we do clean our unallocated resources and yes not to forget we do not get the hit
of running the Garbage collector twice.

Collect:

System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if
situations arises.





Responses

Author: rajesh    12 Aug 2008Member Level: SilverRating:     Points: 3
Yes, UmaShankar is correct..Both of them had copied the answer from Sujaa's thread. Instaed of coping like this give different answers.It vl be easy to understand.


Author: Danasegarane.A    12 Aug 2008Member Level: DiamondRating:     Points: 0
They may also refer the Link

:)


Post Reply
You must Sign In to post a response.
Next : Gift Received
Previous : about search
Return to Discussion Forum
Post New Message
Category: [About DotNetSpider]

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use