N! Xau wrote:
I am kind of a newbie. What's the difference between using dispose()
or = nothing in the 'finally' block of the following code:
Setting the object to Nothing will cause you to lose your reference to the
object, but nothing else will immediately happen (unlike in VB6, where if
this was the only reference then the object would have terminated).
Providing there are no other references to the object, it will be finalized
and garbage collected the next time the garbage collector runs. However, the
resources used by the object will NOT be released until the garbage
collection occurs (which could be some considerable time in the future).
This potentially continues to consume memory and other resources both on the
client (in ADO.NET) and the server (in your Oracle database).
If you Dispose of the object, you explicitly release all resources used by
the object. This will cause it to free all of its memory and properly
terminate itself.
You should therefore always Dispose of your objects as soon as you are
finished with them. You can set them to Nothing afterwards too if you like,
but setting things to Nothing doesn't in itself cause things to be tidied up
any more.
Hope that helps,
--
(O)enone