Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ? Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Go Back  Xtreme Visual Basic Talk > > > Which objects require "DISPOSE" ?


Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2017, 02:18 PM
skyfox's Avatar
skyfox skyfox is offline
Centurion
 
Join Date: Feb 2005
Location: InsideACircularReference
Posts: 190
Default Which objects require "DISPOSE" ?


Can someone please shed some light in as to what the criteria is used in the .NET world for determining which objects require the "Dispose" method to release their resources vs. using "MyObject = Nothing?

Thanks
__________________
SkyFox
Tinker of All, Master of NONE!
"To B or Not To VB? That's the Question"
Reply With Quote
  #2  
Old 01-28-2017, 06:23 PM
PlausiblyDamp's Avatar
PlausiblyDampWhich objects require "DISPOSE" ? PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If you have a class that holds onto non-dotnet resources e.g. file handles, database connections and similar for longer than a single method then your class should implement IDisposable and therefore provide a Dispose method. These resources need to be cleaned up in a timely fashion and the Dispose method is a way of allowing an application to free up these external resources at a know point in time, rather than waiting for the garbage collector to kick in and free them up at some point in the future.

Setting a variable to nothing is often unnecessary in .Net - the runtime tracks when a variable is still accessible or not and setting a variable to nothing can actually keep a variable in memory longer than just letting the GC figure it out.

Setting things to nothing can be useful if you wish to free up a single element in an array or similar, it can also help to free up memory if you have variables at the class level that are no longer needed; within a method though it is probably not needed.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply

Tags
determining, dispose, method, objects, require


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ? Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ? Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
 
Which objects require "DISPOSE" ?
Which objects require "DISPOSE" ?
 
-->