Prev: XSL transforms
Next: Interop.SpeechLib.dll exception
From: Moe Sisko on 11 Jul 2008 01:31 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 11 Jul 2008 01:36 <"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 11 Jul 2008 14:19 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 11 Jul 2008 15:02 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 13 Jul 2008 21:36
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 |