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

Posted on 2009-02-21
Last Modified: 2013-11-13
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

Question by:aibusinesssolutions
    LVL 15

    Assisted Solution

    by:Praveen Venu
    LVL 15

    Author Comment

    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.  
    LVL 15

    Accepted Solution


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This video teaches viewers about errors in exception handling.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now