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 6741167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:41:33+00:00 2026-05-26T11:41:33+00:00

May I know if the objectToBeDisposed will be disposed if its reference are kept

  • 0

May I know if the “objectToBeDisposed” will be disposed if its reference are kept by the “useDisposableObject”?

using(IDisposable objectToBeDisposed = new ObjectImplementedIDisposable  ()){
ChildObject useDisposableObject = new ChildObject(objectToBeDisposed);
.... doing stuff with useDisposableObject;
}
  • 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-26T11:41:34+00:00Added an answer on May 26, 2026 at 11:41 am

    Disposal, finalization and memory deallocation are 3 totally different things in the .NET world.

    Disposal is only an “application logic” thing, it is implemented through the disposable pattern.
    If you implement the interface IDisposable, your object can be used with the using keyword.

    The using keyword will translate in a simple way:

    using (IDisposable xxx = new MyObject())
    {
        ....
    }
    

    means

    {
        IDisposable xxx = new MyObject();
        try
        {
            ....
        }
        finally
        {
            if (xxx != null)
                xxx.Dispose();
        }
    }
    

    There is no other magic in this. That’s all.

    Object finalization is instead called by garbage collector when the objects should be freed.
    The time when it happens and the order between destructors is unpredictable.

    class myclass { ~myclass() { this code will be called by garbage collector, i cannot call it } }
    

    The syntax is very similar to C++ destructors but the meaning is a lot different.

    And then memory deallocation.
    Memory deallocation is not connected to object disposal!
    You can keep forever a reference to a disposed object. Disposal is just something related to application logic.

    Destructors can also be cancelled or called more than once by garbage collector (see GC.ReRegisterForFinalize and GC.SuppressFinalize).
    The presence of a destructor in a class slow down a lot the garbage collector, and inside destructor, you can do almost nothing except releasing unmanaged resources.

    Disposal instead as I said is an application thing, is just a method, and is not related to garbage collector.

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

Sidebar

Related Questions

As you may know, the wall rect will not update since its a copy
As you may know not long time ago facebook added several new features. One
I am using facebox (you may know of it) and my script looks like
As you may know, if you chain jQuery animations together using the complete parameter,
As you may know Coherence provides filtering api against its cache-cluster, like this: //
Using the BTree package at SqueakSource (or any other you may know) and given
As you may know, tonight, at exactly 23:31:30 UTC, Epoch Time will reach 1234567890!
You may know this recommendation from Microsoft about the use of exceptions in .NET:
You may know the scriptaculous SlideUp effect . Well, It slides up a div
As you may know, in VS 2008 ctrl + tab brings up a nifty

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.