From: Moe Sisko on
Using dotnet 2.0,

Just wondering if anyone knows if calling Dispose() on
System.IO.MemoryStream does anything useful.








From: Jon Skeet [C# MVP] on
<"Moe Sisko" <null>> wrote:
> Using dotnet 2.0,
>
> Just wondering if anyone knows if calling Dispose() on
> System.IO.MemoryStream does anything useful.

Nope.

--
Jon Skeet - <skeet(a)pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
From: Pavel Minaev on
On Jul 11, 9:36 am, Jon Skeet [C# MVP] <sk...(a)pobox.com> wrote:
>  <"Moe Sisko" <null>> wrote:
>
> > Using dotnet 2.0,
>
> > Just wondering if anyone knows if calling Dispose() on
> > System.IO.MemoryStream does anything useful.
>
> Nope.

Who knows, maybe it will in a future version of .NET... personally, I
still put all mine in using() anyway.
From: Jeroen Mostert on
Moe Sisko wrote:
> Just wondering if anyone knows if calling Dispose() on
> System.IO.MemoryStream does anything useful.
>
Yes, it calls Stream.Dispose(), which in turn will dispose an event created
as a result of calling asynchronous methods (.BeginRead(), .BeginWrite())
if they were not all finished before the stream was finalized.

So you better call .Dispose(), or you might leak a single event handle in
very unlikely circumstances!

--
J.
From: Arne Vajhøj on
Pavel Minaev wrote:
> On Jul 11, 9:36 am, Jon Skeet [C# MVP] <sk...(a)pobox.com> wrote:
>> <"Moe Sisko" <null>> wrote:
>>> Using dotnet 2.0,
>>> Just wondering if anyone knows if calling Dispose() on
>>> System.IO.MemoryStream does anything useful.
>> Nope.
>
> Who knows, maybe it will in a future version of .NET... personally, I
> still put all mine in using() anyway.

I can not imagine MemoryStream ever holding unmanaged data.

But I still agree with the conclusion: call Dispose on anything
that implements IDisposable is a good thing.

Arne
 |  Next  |  Last
Pages: 1 2
Prev: XSL transforms
Next: Interop.SpeechLib.dll exception