From: Patrice on 21 Mar 2010 15:41 > The first question . "Uses more memory when working with file system" > should be connected to the FileStream. > Can somebody explain why FileStream is considered as the right answer to > that question Someone else answered. > The second question. "Provides better performance over FileStream" should > be connected to MemoryStream." > I find that the BufferedStream is just as good answer as the MemoryStream. A possible explanation is that a buffered stream assumes that you are reading precisely from something that needs buffering (ie. data needs to be transfered). With a memory stream you are pretty sure that the data is readily available from memory so you always read from memory. So it provides a better performance. -- Patrice
From: Göran Andersson on 22 Mar 2010 06:27 Tony Johansson wrote: > Hi! > > If you have these two question that says the following. > 1. Uses more memory when working with file system. > 2. Provides better performance over FileStream > > and each of these question should be connected to one of these > FileStream, MemoryStream or BufferedStream. > > The first question . "Uses more memory when working with file system" should > be connected to the FileStream. > Can somebody explain why FileStream is considered as the right answer to > that question The question is a bit unclear, it's not certain if it refers to one class that has different characteristics depending on whether it's used against the file system, or if it refers to different classes that can be used against the file system. If it is the first, then it's only the BufferedStream that has the option to be used with both the file system and something else. If it's the second, then it would also be the BufferedStream, as that would wrap a FileStream and also allocate buffers in memory. The FileStream is the one class that uses the least memory of the options, so I can't see how that would be the correct answer in any case. > The second question. "Provides better performance over FileStream" should be > connected to MemoryStream." > I find that the BufferedStream is just as good answer as the MemoryStream. > So again can somebody explain why MemoryStream is considered as the right > answer to that question File I/O is already buffered (as you can't access anything smaller than a cluster in the end), so wrapping a FileStream in a BufferedStream doesn't guarantee any real improvement. A MemoryStream on the other hand is significantly faster than using a FileStream. However, this question is also a bit unclear. It could also be read as identifying the class that could possibly improve the performance of a FileStream, and then the BufferedStream would be the only option. -- G�ran Andersson _____ http://www.guffa.com
First
|
Prev
|
Pages: 1 2 Prev: using BufferReader together wiith StreamReader Next: Accessing a Profile Value from a Class |