Using dotnet 2.0,
Just wondering if anyone knows if calling Dispose() on
System.IO.MemoryStream does anything useful. 8 8111
On Jul 11, 9:36*am, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
*<"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.
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.
Pavel Minaev wrote:
On Jul 11, 9:36 am, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
> <"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
Jeroen Mostert wrote:
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!
It uses unmanaged resources ?
Arne
Arne Vajhøj wrote:
Jeroen Mostert wrote:
>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!
It uses unmanaged resources ?
Indirectly, yes. But only in the circumstances described above.
--
J.
Arne Vajhøj wrote:
Jeroen Mostert wrote:
>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!
It uses unmanaged resources ?
Indirectly, yes. But only in the circumstances described above.
--
J.
Arne Vajhøj wrote:
Jeroen Mostert wrote:
>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!
It uses unmanaged resources ?
Indirectly, yes. But only in the circumstances described above.
--
J. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BH |
last post by:
I'm trying a simple object serialization and deserialization, and keep
getting this error:
System.Runtime.Serialization.SerializationException: Binary stream does not
contain a valid...
|
by: Barry Anderberg |
last post by:
I'm using a tool by Sci-Tech called the .NET Memory Profiler.
We have a massive .NET/C# application here and it has been exhibiting
memory leak behavior for some time. Attempting to remedy the...
|
by: Greg Patrick |
last post by:
My problem:
I load an some assemblies (strong named) from a byte array using
Assembly.Load(byte). They load fine. But one one of them is actually
accessed, it's referenced assemblies can't be...
|
by: Mike Collins |
last post by:
I apologize for using this newsgroup for what seems like a VB6 question, but
I did not see a newsgroup for VB6. I also think I may not have the C# code
setup correctly for calling from VB6. If...
|
by: Oleg Subachev |
last post by:
I use local to methods MemoryStreams.
Both read-only and read-write ones.
Do I need to call MemoryStream.Close for read-only MemoryStreams before
leaving the method ?
And what about...
| |
by: Ken |
last post by:
How can I have my WinForm return something to the caller so it knows which
button is clicked? The following is calling a system message box, just want
to do the samething with my own winform....
|
by: Tony Sinclair |
last post by:
I'm just learning C#. I'm writing a program (using Visual C# 2005 on
WinXP) to combine several files into one (HKSplit is a popular
freeware program that does this, but it requires all input and...
|
by: active |
last post by:
In the main program I check to see if a certain form has been disposed.
Does it make sense in that form's FormClosed event to do:
Me.Dispose to make sure it is disposed the next time I check.
Or...
|
by: Claire |
last post by:
Hi
I have a function that sends email messages plus attachments.
I'm worried about the memorystream I'm using in the following clipped code
sample.
Will it be closed/disposed of without me doing...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |