I
Imran Koradia
why would one want to use a MemoryStream?
it basically creates a stream in memory to read/write data from/to memory -
which we can accomplish with our regular objects as well. We could read
strings/bytes etc from files using the FileStream (or from network using
NetworkStream) into the relevant .NET object and work on it as long as we
wish. if needed to have the data in memory for future use, we can just leave
the object hanging around as long as we want to make use of the data .
the only thing different i would think is that while objects within the
application basically stick to the address space that the OS assigns to the
process for the application, the memorysteam is free to read/write from/to
memory thats outside the application scope. is this correct? if so, are
there any performance implications if we leave a large amount of data
hanging around in the application-specific memory as opposed to writing it
somewhere else in memory and reading it back when needed (consider reading a
large text file into a stringbuilder and leaving it hanging around for the
entire application lifetime as opposed to writing it to memory using a
MemoryStream and reading it back when needed)?
just ran into thoughts while reading about .NET Stream objects..
any input/feedback is greatly appreciated.
Imran.
it basically creates a stream in memory to read/write data from/to memory -
which we can accomplish with our regular objects as well. We could read
strings/bytes etc from files using the FileStream (or from network using
NetworkStream) into the relevant .NET object and work on it as long as we
wish. if needed to have the data in memory for future use, we can just leave
the object hanging around as long as we want to make use of the data .
the only thing different i would think is that while objects within the
application basically stick to the address space that the OS assigns to the
process for the application, the memorysteam is free to read/write from/to
memory thats outside the application scope. is this correct? if so, are
there any performance implications if we leave a large amount of data
hanging around in the application-specific memory as opposed to writing it
somewhere else in memory and reading it back when needed (consider reading a
large text file into a stringbuilder and leaving it hanging around for the
entire application lifetime as opposed to writing it to memory using a
MemoryStream and reading it back when needed)?
just ran into thoughts while reading about .NET Stream objects..
any input/feedback is greatly appreciated.
Imran.