Questions tagged [buffer]

A buffer is an area of memory set aside for temporary storage of data while it is being moved from one place to another. This is typically done to speed up processes with significant latency, such as writing to a disk, printer or other physical device. The output is ready to be sent to the device before the device is ready to accept it, so it is moved to the buffer so that the sending program does not have to continue waiting.

A may be used when moving data between processes within a computer. This is comparable to buffers in telecommunication. Buffers can be implemented in a fixed memory location in hardware—or by using a virtual data buffer in software, pointing at a location in the physical memory. In all cases, the data stored in a data buffer are stored on a physical storage medium. A majority of buffers are implemented in software, which typically use the faster RAM to store temporary data, due to the much faster access time compared with hard disk drives. Buffers are typically used when there is a difference between the rate at which data is received and the rate at which it can be processed, or in the case that these rates are variable, for example in a printer spooler or in online video streaming.


References

7035 questions
689
votes
16 answers

How can I clear previous output in Terminal in Mac OS X?

I know the clear command that 'clears' the current screen, but it does this just by printing lots of newlines - the cleared contents just get scrolled up. Is there a way to completely wipe all previous output from the terminal so that I can't reach…
eonil
  • 83,476
  • 81
  • 317
  • 516
565
votes
10 answers

How do I close a single buffer (out of many) in Vim?

I open several files in Vim by, for example, running vim a/*.php which opens 23 files. I then make my edit and run the following twice :q which closes all my buffers. How can you close only one buffer in Vim?
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
232
votes
9 answers

What does it mean by buffer?

I see the word "BUFFER" everywhere, but I am unable to grasp what it exactly is. Would anybody please explain what is buffer in layman's language? When is it used? How is it used?
Pratik Deoghare
  • 35,497
  • 30
  • 100
  • 146
222
votes
5 answers

What is the use of ByteBuffer in Java?

What are example applications for a ByteBuffer in Java? Please list any example scenarios where this is used.
Aklin
  • 2,621
  • 2
  • 17
  • 17
215
votes
14 answers

Convert a binary NodeJS Buffer to JavaScript ArrayBuffer

How can I convert a NodeJS binary buffer into a JavaScript ArrayBuffer?
Drake Amara
  • 3,072
  • 3
  • 19
  • 18
199
votes
14 answers

What is the difference between buffer and cache memory in Linux?

To me it's not clear what's the difference between the two Linux memory concepts : buffer and cache. I've read through this post and it seems to me that the difference between them is the expiration policy: buffer's policy is first-in,…
James.Xu
  • 8,249
  • 5
  • 25
  • 36
189
votes
12 answers

Save Screen (program) output to a file

I need to save the whole output of Screen to a file to check later all the content. The reason is that I'm dumping a flash memory through a serial port, using Screen to interface with it. I would like to save it to a file to check memory…
Edoardoo
  • 2,739
  • 4
  • 18
  • 27
180
votes
3 answers

Convert a JSON Object to Buffer and Buffer to JSON Object back

I have a JSON object and I'm converting it to a Buffer and doing some process here. Later I want to convert the same buffer data to convert to valid JSON object. I'm working on Node V6.9.1 Below is the code I tried but I'm getting [object object]…
Prasanth J
  • 1,803
  • 2
  • 8
  • 4
176
votes
10 answers

How do you determine the ideal buffer size when using FileInputStream?

I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize performance? Most everyone is familiar with the basic…
ARKBAN
  • 3,419
  • 4
  • 24
  • 22
169
votes
7 answers

Force line-buffering of stdout in a pipeline

Usually, stdout is line-buffered. In other words, as long as your printf argument ends with a newline, you can expect the line to be printed instantly. This does not appear to hold when using a pipe to redirect to tee. I have a C++ program, a, that…
houbysoft
  • 32,532
  • 24
  • 103
  • 156
159
votes
9 answers

Converting a Buffer into a ReadableStream in Node.js

I have a library that takes as input a ReadableStream, but my input is just a base64 format image. I could convert the data I have in a Buffer like so: var img = new Buffer(img_string, 'base64'); But I have no idea how to convert it to a…
Masiar
  • 20,450
  • 31
  • 97
  • 140
157
votes
6 answers

How large should my recv buffer be when calling recv in the socket library

I have a few questions about the socket library in C. Here is a snippet of code I'll refer to in my questions. char recv_buffer[3000]; recv(socket, recv_buffer, 3000, 0); How do I decide how big to make recv_buffer? I'm using 3000, but it's…
adhanlon
  • 6,407
  • 13
  • 43
  • 41
152
votes
6 answers

C char array initialization: what happens if there are less characters in the string literal than the array size?

I'm not sure what will be in the char array after initialization in the following ways. 1.char buf[10] = ""; 2. char buf[10] = " "; 3. char buf[10] = "a"; For case 2, I think buf[0] should be ' ', buf[1] should be '\0', and from buf[2] to…
lkkeepmoving
  • 2,323
  • 5
  • 25
  • 31
151
votes
8 answers

Reading and writing binary file

I'm trying to write code to read a binary file into a buffer, then write the buffer to another file. I have the following code, but the buffer only stores a couple of ASCII characters from the first line in the file and nothing else. int…
nf313743
  • 4,129
  • 8
  • 48
  • 63
144
votes
8 answers

How to delete multiple buffers in Vim?

Assuming I have multiple files opened as buffers in Vim. The files have *.cpp, *.h and some are *.xml. I want to close all the XML files with :bd *.xml. However, Vim does not allow this (E93: More than one match...). Is there any way to do…
Thanh DK
  • 4,257
  • 3
  • 23
  • 18
1
2 3
99 100