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
57
votes
5 answers

Why doesn't Ruby have a real StringBuffer or StringIO?

I recently read a nice post on using StringIO in Ruby. What the author doesn't mention, though, is that StringIO is just an "I." There's no "O." You can't do this, for example: s = StringIO.new s << 'foo' s << 'bar' s.to_s # => should be…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
54
votes
6 answers

How to redirect ex command output into current buffer or file?

How can I redirect or pipe the output of an ex command into my current buffer or a file? For example, I want to read the contents of all the registers into the current buffer, which in ex mode is shown using :registers.
Aman Jain
  • 10,927
  • 15
  • 50
  • 63
49
votes
2 answers

Vim: Replace selection with default buffer without overwriting the buffer

Here is my problem: I am in visual mode. I select text and copy it to the buffer. ((y)ank) I select another text which I want to replace and paste the buffer. ((p)aste) Now the second selection has been replaced in the buffer, however I want the…
Juergen Riemer
  • 1,393
  • 2
  • 13
  • 29
49
votes
3 answers

How can I save my mini-buffer history in Emacs?

I'd like to save, for instance, my find-file and Meta-X history in Emacs' mini-buffer so I can recall commands later in a different session.
Jonathon Watney
  • 20,248
  • 9
  • 38
  • 40
48
votes
2 answers

Use of Vertex Array Objects and Vertex Buffer Objects

I am trying to understand these two, how to use them and how they are related. Let's say I want to create a simple terrain and a textured cube. For both objects I have the array of triangles vertices and for the cube I have an array containing the…
ali
  • 10,927
  • 20
  • 89
  • 138
47
votes
4 answers

Why is it good to close() an InputStream?

Why is it necessary to close() java.io.InputStream or its subclasses? Now with java.io.OutputStream, say FileOutputStream, after writing to a file, if we don't close() the output stream, the data that we intended to write in the file remains in the…
Aditya Singh
  • 2,343
  • 1
  • 23
  • 42
46
votes
5 answers

Buffered files (for faster disk access)

I am working with large files and writing directly to disk is slow. Because the file is large I cannot load it in a TMemoryStream. TFileStream is not buffered so I want to know if there is a custom library that can offer buffered streams or should I…
Gabriel
  • 20,797
  • 27
  • 159
  • 293
46
votes
5 answers

How to open file in Emacs via eshell?

When in eshell is there a command for opening a file in another buffer?
hks
  • 757
  • 1
  • 6
  • 13
46
votes
1 answer

How to know actual size of byte buffer`s content in nodejs?

I get files as byte buffers and cannot use fs.stat() method. So I am try to use buf.length but this length refers to the amount of memory allocated for the buffer object and not actually the content size. For example I have file with with size…
lor1an
  • 654
  • 2
  • 6
  • 14
44
votes
4 answers

std::cout won't print

Is there any circumstance when std::cout << "hello" doesn't work? I have a C++ program where std::cout doesn't seem to print anything, not even constant strings (such as "hello"). Is there any way to check if cout is able/unable to open the stream?…
mahmood
  • 23,197
  • 49
  • 147
  • 242
43
votes
4 answers

elisp regexp search in strings, not buffers

I have been searching everywhere in the emacs lisp documentation for how to regular expressions search into a string. All I find is how to do this in buffers. Is there something I'm missing? Should I just spit my string into a temporary buffer and…
Eli
  • 2,041
  • 4
  • 18
  • 20
43
votes
1 answer

What are the differences between readable and data event of process.stdin stream?

say I have process.stdin.setEncoding('utf8'); var myString = ''; What are the differences between process.stdin.on('readable', function() { myString += process.stdin.read(); }); and process.stdin.on('data', function(chunk) { myString +=…
stevemao
  • 1,423
  • 1
  • 16
  • 29
42
votes
3 answers

What is a buffer in Node.js?

As you can read in the Node.js documentation on the Buffer class, a buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. So far, so good. What now puzzles me is the question what a buffer is…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
42
votes
5 answers

What is the use of -fno-stack-protector?

I have written an application in C, and I'm trying to understand what is the purpose of the -fno-stack-protector command when compiling. For my specific application, it makes no difference if I use this command or not in terms of protecting against…
touvlo2000
  • 505
  • 1
  • 5
  • 9
37
votes
7 answers

Display Pdf in browser using express js

I'm trying to serve a PDF via Express in a way it is displayed in browser: app.post('/asset', function(request, response){ var tempFile="/home/applmgr/Desktop/123456.pdf"; fs.readFile(tempFile, function (err,data){ …
Dexter
  • 12,172
  • 9
  • 27
  • 30