Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dispose and nothing? whats the main difference?

Reply
Thread Tools

dispose and nothing? whats the main difference?

 
 
=?Utf-8?B?QXNoYQ==?=
Guest
Posts: n/a
 
      07-14-2004
greetings,
should i do this

obj.dispose

then

obj = nothing

both does the same thing right? whats the core difference?
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      07-14-2004
"Asha" <> wrote in message
news:0B36A059-E110-45D0-B6D3-...
> greetings,
> should i do this
>
> obj.dispose
>
> then
>
> obj = nothing
>
> both does the same thing right? whats the core difference?


No. obj = nothing doesn't do anything anymore. It simply removes one
reference to the object. If that's the last reference to the object, then
the object may eventually be garbage-collected.

Dispose cleans up whatever the object thinks needs to be cleaned up, and
does it immediately.
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2FyYXZhbmFuIER1cmFp?=
Guest
Posts: n/a
 
      07-14-2004
Dispose method is used to clean up the unwanted resources like sqlconnections,command objects,

dispose method will be called automatically if we create the instance in the following way

using ( DBreader reader=sp.executereader)
{

}

if DBreader is implemented idisposable interface then dispose method will be called
automatically at the end of scope,

nothing is used to remove the reference of the object even if we force the object to nothing, it will take some time to relaese the reference by the garbage.
"Asha" wrote:

> greetings,
> should i do this
>
> obj.dispose
>
> then
>
> obj = nothing
>
> both does the same thing right? whats the core difference?

 
Reply With Quote
 
Scott Allen
Guest
Posts: n/a
 
      07-14-2004
On Tue, 13 Jul 2004 21:37:01 -0700, Saravanan Durai <Saravanan
> wrote:

>Dispose method is used to clean up the unwanted resources like sqlconnections,command objects,
>
>dispose method will be called automatically if we create the instance in the following way
>
>using ( DBreader reader=sp.executereader)
>{
>
>}
>
>if DBreader is implemented idisposable interface then dispose method will be called
>automatically at the end of scope,
>

In fact, the only objects you can put inside a using clause are
objects implementing IDisposable!

--s
--
Scott
http://www.OdeToCode.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how #define a main() function and call our own main function? ravi C Programming 28 09-26-2007 01:33 AM
use of MySQLConnection.dispose and/or MySQLCommand.dispose Antonio Concepcion ASP .Net 3 02-17-2005 06:33 PM
whats the use of third argument to main( ) thesushant@rediffmail.com C Programming 6 01-11-2005 03:59 PM
Main > Popup > Popup > Close popup AND new URL in main? Jens Peter Hansen Javascript 7 06-19-2004 08:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57