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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:08:18+00:00 2026-05-11T02:08:18+00:00

None of the guides/notes/articles that discuss IDisposable pattern suggest that one should set the

  • 0

None of the guides/notes/articles that discuss IDisposable pattern suggest that one should set the internal members to null in the Dispose(bool) method (especially if they are memory hogging beasts).

I’ve come to realize the importance of it while debugging an internal benchmark tool. What used to happen was that, there was this buffer that contained a big array inside it. We used to use a static buffer for the whole benchmark program. Once we’re done with the buffer, there was no way we could release this internal array, neither could we make this buffer releasable (as it was static).

So, I believe that, after Dispose() is called, the class should do everything it can so that it releases all the resources it is using and make them available again, even if the object being disposed itself is not collected back by GC, and not setting members to null, thereby, not allowing the internal objects to be collected by the GC implies that the Dispose implementation is not perfect.

What’s your opinion on this ?

  • 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. 2026-05-11T02:08:18+00:00Added an answer on May 11, 2026 at 2:08 am

    Releasing any additional references during Dispose is certainly something I try to do, for two reasons:

    • it allows the inner objects to be garbage collected even if the disposed object is still in scope
    • if the inner objects are disposable, it means we only dispose them once even if Dispose() is called repeatedly on the outer object

    For example, I tend to use things like:

    if(someDisposableObject != null) {     someDisposableObject.Dispose();     someDisposableObject = null; } (for non-disposable, just set to null) someNonDisposableObject = null; // etc 

    You might also want to set any events to null:

    someEventHandler = null; 

    This can help minimise the impact if the caller can’t fully release their reference (or simply forgets) at the moment. While you should try to release the outer object (for GC), it is relatively easy to accidentally extend the life of the object, for example via a captured variable (anonymous method/lambda), an event, etc.

    If you have a finalizer, then during the GC process there is no benefit doing this, and you shouldn’t really call methods on external objects (even Dispose()) – so in short: don’t do any of this during a GC sweep.

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

Sidebar

Related Questions

How can I set display:none to a ul if only has a single child?
I admit that I have almost none experience of unittesting. I did a try
I know that the follwoing line used in jquery to set the property of
I am creating a form wizard that guides the user through each form element,
I am seeing a conflict between what Rails 3.1 guides suggest, and what Google
None of us started off as experts (and most of us still aren't). Sure,
does Display:none or jquery Hide function speed up my website, i mean i'm developing
I googled,I checked wikipedia.None of them helped me to find an official java compiler
I have a script which hides (display:none) certain divs in the list on page
my style is here #mybox{ display:none; } my web is here <div id='mybox'> ...

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.