Disposing, dereferencing and releasing memory when a program closes

Posted on 2009-04-18
Last Modified: 2013-11-27
Hello Experts

I believe that when I dereference a component, using (say) "customer = Nothing", that this means I can no longer use the component. I also believe that at some time later Garbage Collection will release the memory but until that happens the memory is unavailable for use.

I think that Dispose releases it immediately.

My question is, what is the correct sequence of actions to release resources when an application terminates?
Question by:jindalee
    LVL 3

    Accepted Solution

    Try Reading This:

    In VB.NET, setting to Nothing does not give special help in releasing the memory. Calling Dispose() will release all unmanaged resources (non-.NET resources).

    Just make sure you Dispose everything that you can dispose and let .NET do the job.

    Or you can force GC to mark the collection by reading the above solution.
    LVL 1

    Author Closing Comment

    Thank you. Good article and very useful.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now