• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is a "buffer"?  RSS feed

 
akol ompen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you give me an ecample what is the use of buffer because i cant understand it?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The term "buffer" is a general term in computing ... so ... we definitely don't have enough context to answer your question.

Henry
 
Vaishakh Menon
Greenhorn
Posts: 18
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are asking about a Buffer in Computing....


A buffer is simply a chunk of memory used to hold data.


Please read the below link:

https://docs.oracle.com/javase/7/docs/api/java/nio/Buffer.html

If you want a real world example then think of the below scenario:

Imagine that you're eating candy out of a bowl. You take one piece regularly. To prevent the bowl from running out, someone might refill the bowl before it gets empty, so that when you want to take another piece, there's candy in the bowl.

The bowl acts as a buffer between you and the candy bag.

If you're watching a movie online, the web service will continually download the next 5 minutes or so into a buffer, that way your computer doesn't have to download the movie as you're watching it (which would cause hanging).
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vaishakh gives a good explanation. To add to it, a buffer sits between two processes that operate at different  rates. The buffer is kind of a reservoir that allows one side of an interaction to continue either adding to or drawing from the pool of resources without having to wait for the other side to finish what it's doing.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To clarify the role of a buffer in the online movie streaming example, the two processes that are separated by a buffer are the displaying process and the  downloading process. The rate at which the downloading process operates is often not consistent enough for the display process to operate smoothly. You don't want to watch movies that are choppy, right? A buffer holds a chunk of the movie that the display process can reliably read at a constant rate. The download process can continue operating at a different and perhaps more inconsistent rate that is dependent on network speed, latency and other factors.

So in this sense,  a buffer also acts like a car's shock absorber, smoothing out the "ride" felt on one side despite having small bumps, starts, and stops on the other side.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!