calling all the IT experts here. anyone can explain what is buffer size in layman terms? eg: what is means when the buffer size is 2mb. pls post the answer asap thanks
ditzy
Imagine a giant spring that stops a moving train hitting the wall, imagine the buffer size to be the length of that spring, the shorter the spring, the bigger the knock.
ha8n
think of a standard size plastic bag with the maximum load it can contain
ditzy
Now imagine diving into a tank of water, imagine the buffer size to be the depth of the tank of water, would you prefer to land in 10 feet of water or 10cm of water?
Weirdo80
Geez, the explanations so far have been nonsensical.....
There are all sorts of buffers, memory buffers, file buffers, network buffers, etc but all fulfill roughly the same function: to facilitate some sort of input/output into the system.
Think of reading a file as trying to get water out of a large water tank. The buffer size is the size of the pail that you scoop water out with. If you use a large pail, water will come out faster. However, if the amount of water is less than the size of the pail, then the extra space in the pail is wasted. For time-sensitive I/O operations (e.g. network buffering), the system may have to wait for the whole "pail" to be filled before moving on to the next step, and therefore it may actually impede performance (also has to do with fragmenting, but that's another topic). Also, the larger the "pail", the more system resources the buffer uses in its operation.
For example, let's say you're trying to read a 10MB file over the network. You can easily use a 10MB network buffer to read the whole file at a time, but such a large buffer may be unavailable to lower-end systems. It will probably make more sense to use say a 10kb buffer to transfer the file. The procedure will then be:
1) Declare the buffer (e.g. byte[] net_buff=new byte[1024])
2) Open the network stream
3) Read data into the buffer
4) Append the data in the buffer to a file
5) If not end of file then go to step 3 else continue
6) Close the stream and free the buffer
On the kernel level, the OS will probably perform buffer optimizations for you so your small buffer may actually have better performance than a large buffer.
The trick is then to determine the optimal buffer size for I/O operations. This is highly dependant on the application and the context of the required operations. That is why in most games (e.g. Countrstrike), there is an option to allow you to select the network speed (56k, ISDN, Cable, etc). This effectively changes your maximum transfer unit (MTU) which is somewhat like changing the buffer size.