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 !




Con.close()


Posted Date: 19 Jul 2008      Total Responses: 2

Posted By: Jessie       Member Level: Gold     Points: 1



Why should we explicity close some objects like connection,filestream ? Wont GC takes care of it?




Responses

Author: Kumar Velu    19 Jul 2008Member Level: DiamondRating:     Points: 6

Web applications frequently establish the database connection and close them as soon as they are done. Also notice how most of us write the database driven client applications. Usually, we have a configuration file specific to our application and keep the static information like Connection String in it. That intern means that most of the time we want to connect to same database server, same database, and with same user name and password, for every small and big data.

ADO.NET with IIS uses a technique called Connection Pooling, which is very helpful in applications with such designs. What it does is, on first request to database, it serves the database call. Once it is done and when client application requests for closing the connection, ADO.NET does not destroy the complete connection rather it creates a connection pool and puts the released connection object in the pool and holds the reference to it. And next time when the request to execute any query/stored proc comes up, it bypasses the hefty process of establishing the connection and just picks up the connection from the connection pool and uses that for this database call. This way, it can return the results faster comparatively.

More details about:
http://www.dotnetspider.com/resources/406-What-Garbage-Collection-GC.aspx
http://www.dotnetspider.com/resources/406-What-Garbage-Collection-GC.aspx



Author: Bindu Bujji    20 Jul 2008Member Level: GoldRating:     Points: 2

Hi
Refer the link below.
http://www.dotnetspider.com/resources/406-What-Garbage-Collection-GC.aspx



Bindu



Post Reply
You must Sign In to post a response.
Next : Interview Questions
Previous : Differences
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use