Disposing, dereferencing and releasing memory when a program closes

Posted on 2009-04-18
Medium Priority
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

Accepted Solution

doraemon2555 earned 2000 total points
ID: 24177704
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.

Author Closing Comment

ID: 31571895
Thank you. Good article and very useful.

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

809 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