• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 949
  • Last Modified:

What is the standard Buffer size of a NetworkStream or FileStream?

I've been working on a simple client/server backup app, and I can't seem to find an answer to this anywhere.  What is the normal size that people use for their buffer length? What is a good size to keep memory usage low but execute file read/writes on large files fairly quickly?

Is there a standard?  I notice that most people use multiples of 1024.  2048, 4096, 8192, etc.

Here's an example of what I'm doing, this is used on both local file read/writes and network read/writes in my app.  As you can see I am using 4096 at the moment.  
    bytesRead = strm1.Read(bBuffer, 0, 4096)
    If bytesRead > 0 Then
        strm2.Write(bBuffer, 0, bytesRead)                
    End If
Loop While bytesRead > 0

Open in new window

  • 2
2 Solutions
aibusinesssolutionsAuthor Commented:
Thanks praveenvenu, but that doesn't really answer my question.  They are talking about reading a text file line by line, or in 200 byte chunks.  One person says that 2048 is optimal buffer length, but doesn't mention WHY 2048 is optimal.  
aibusinesssolutionsAuthor Commented:

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now