Re: Dispose Again!
On 2005-03-22, Scott M. <s-mar@nospam.nosp am> wrote:[color=blue][color=green]
>> Your saying that Dispose is present because of the IDE and not the final
>> running application and that in that final running application, Dispose
>> has
>> no use.[/color]
>[color=green][color=darkred]
>>>>I'm saying that's true in some cases.[/color][/color]
>
> Well, actually you didn't say that the first time,[/color]
Okay, let's see what I actually said...
Most commonly, there's an awful lot of objects that don't need to be
disposed at runtime but have a visual representation of themselves in
Visual Studio that *does* need to be disposed.
That's pretty straightforward . Some objects need runtime disposing, but
there's a lot of objects that don't, even if those objects might need
design-time disposing.
Originally you disagreed that this was even possible. Do you still hold
that opinion?
you said:[color=blue]
>[color=green][color=darkred]
>>> Web controls are the perfect example of that. At design time, they need
>>> to be disposed otherwise you'll squander windows resources. But at
>>> runtime, there's nothing to dispose. Also, if you think about it,
>>> there's no reasonable time for user code to dispose a web control at
>>> runtime (Page.Unload maybe?).[/color][/color]
>
> What I got from this was you saying "you don't need to dispose web form
> controls at run-time". And this is not true. As you say an OleDb
> connection object at run-time will be holding on to unmanaged resources that
> do not have anything to do with GDI and so this connection object should be
> disposed at run-time.[/color]
An OleDbConnection isn't a web control.
[color=blue][color=green]
>> That is what I take issue with, that is what is completely false.[/color]
>[color=green][color=darkred]
>>>>Well, gee, it's hard to argue with that impeccable logic. And you've
>>>>backed up your argument so well here with, well, pretty much nothing.[/color][/color]
>
> And, gee, your sarcasm is something we can do without as well.[/color]
Perhaps you're right.
[color=blue]
> Do you
> disagree that OleDb connections hold unmanaged resources? What part of
> saying that an OleDb connection needs to be disposed at run-time do you
> disagree with?[/color]
Short answer: yes, you should dispose an OleDbConnection at runtime.*
* Longer answer, OleDbConnection is one of the most complex examples
there is. The problem is the subtle differences between Close and
Dispose on an OleDbConnection , and also the effect that Dispose and
FreeCoTaskMem can have on the connection pool and the interface with the
actual DB provider. In truth, I honestly don't know the answer
(although profiling seems to imply that it really doesn't matter much
either way). Mind you, you should definitely *Close* an
OleDbConnection , but Close and Dispose aren't the same thing, despite
what a lot of the docs say.
On 2005-03-22, Scott M. <s-mar@nospam.nosp am> wrote:[color=blue][color=green]
>> Your saying that Dispose is present because of the IDE and not the final
>> running application and that in that final running application, Dispose
>> has
>> no use.[/color]
>[color=green][color=darkred]
>>>>I'm saying that's true in some cases.[/color][/color]
>
> Well, actually you didn't say that the first time,[/color]
Okay, let's see what I actually said...
Most commonly, there's an awful lot of objects that don't need to be
disposed at runtime but have a visual representation of themselves in
Visual Studio that *does* need to be disposed.
That's pretty straightforward . Some objects need runtime disposing, but
there's a lot of objects that don't, even if those objects might need
design-time disposing.
Originally you disagreed that this was even possible. Do you still hold
that opinion?
you said:[color=blue]
>[color=green][color=darkred]
>>> Web controls are the perfect example of that. At design time, they need
>>> to be disposed otherwise you'll squander windows resources. But at
>>> runtime, there's nothing to dispose. Also, if you think about it,
>>> there's no reasonable time for user code to dispose a web control at
>>> runtime (Page.Unload maybe?).[/color][/color]
>
> What I got from this was you saying "you don't need to dispose web form
> controls at run-time". And this is not true. As you say an OleDb
> connection object at run-time will be holding on to unmanaged resources that
> do not have anything to do with GDI and so this connection object should be
> disposed at run-time.[/color]
An OleDbConnection isn't a web control.
[color=blue][color=green]
>> That is what I take issue with, that is what is completely false.[/color]
>[color=green][color=darkred]
>>>>Well, gee, it's hard to argue with that impeccable logic. And you've
>>>>backed up your argument so well here with, well, pretty much nothing.[/color][/color]
>
> And, gee, your sarcasm is something we can do without as well.[/color]
Perhaps you're right.
[color=blue]
> Do you
> disagree that OleDb connections hold unmanaged resources? What part of
> saying that an OleDb connection needs to be disposed at run-time do you
> disagree with?[/color]
Short answer: yes, you should dispose an OleDbConnection at runtime.*
* Longer answer, OleDbConnection is one of the most complex examples
there is. The problem is the subtle differences between Close and
Dispose on an OleDbConnection , and also the effect that Dispose and
FreeCoTaskMem can have on the connection pool and the interface with the
actual DB provider. In truth, I honestly don't know the answer
(although profiling seems to imply that it really doesn't matter much
either way). Mind you, you should definitely *Close* an
OleDbConnection , but Close and Dispose aren't the same thing, despite
what a lot of the docs say.
Comment