Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:50:22+00:00 2026-05-27T20:50:22+00:00

If I do a conn.Dispose(); (where conn is an instance of a SqlConnection Class),

  • 0

If I do a conn.Dispose(); (where conn is an instance of a SqlConnection Class), will that clear the conn object from the heap?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:50:22+00:00Added an answer on May 27, 2026 at 8:50 pm

    No, calling Dispose doesn’t clear the connection from the heap. When you call the Dispose method on a SqlConnection instance all you do is return the connection to the underlying connection pool. It doesn’t even close the connection. ADO.NET uses a connection pool. So when you create a new instance of SqlConnection you do not open a new connection, you simply draw a connection from the connection pool and when you call Dispose you simply return this connection to the connection pool so that it can be reused.

    In general the IDisposable pattern in .NET is intended to be implemented by classes that hold some pointers to some unmanaged resources. Calling the Dispose method ensures that those unmanaged resources will be properly released.

    Deleting an object from the heap is what the Garbage Collector does and when this happens is a non-deterministic event (you have no control over it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is this DB-connection-like object that my web application will need. It is pretty
I understand that if I instantiate a SqlConnection object, I am really grabbing a
Can I attach an event to an SqlCommand.Disposed event that will dispose of the
include(conn.php); $result = mysql_query(SELECT * FROM sggame); while($row = mysql_fetch_assoc($result)); { $id = $row['id'];
Assume the following code: using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand
I have a Business Layer that passes a Conn string and a SQLCommand to
I have a bunch of python methods that follow this pattern: def delete_session(guid): conn
I have a base type that I want to inherit from, for all my
I created a DB using following code. Dim conn As New SqlConnection(Server=.\SQLExpress;Data Source=;Integrated Security=SSPI)
I have the following code that uses Sequence objects to read data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.