[Mono-devel-list] System.IO.FileStream patch

eric lindvall eric at 5stops.com
Thu Jun 19 17:52:41 EDT 2003

Is there a reason for your double "if (buf == null)" checks?

+                               } else if (buf == null) {
+                                       if (buf == null) buf = new byte [buf_size];


On Thu, 19 Jun 2003, Ben Maurer wrote:

> Hello,
> I noticed while doing some IO stuff that when FileStream is created it
> always allocates a buffer, even if not necessary. For example, if the
> user allocates a large buffer for use by the read method, it is
> unnecessary to allocate the FileStream buffer.
> Some real life examples of this would be tools that read data from a lot
> of files, such as a compression tool, or a compiler.
> This patch solves that issue by allocating the buffer on first use. All
> the System.IO tests that were previously green are still green with this
> patch. As a test for its effectiveness, I tested with the monodoc
> assembler. It was able to reduce the memory consumption of the program
> by 15 MB.
> -- Ben

More information about the Mono-devel-list mailing list