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

endl and flushing the buffer

In the C++ primer book, in chapter (1), it mentions the following: endl is a special value, called a manipulator, that when written to an output stream has the effect of writing a newline to the output and flushing the buffer associated with…
Simplicity
  • 47,404
  • 98
  • 256
  • 385
36
votes
8 answers

Char array to hex string C++

I searched char* to hex string before but implementation I found adds some non-existent garbage at the end of hex string. I receive packets from socket, and I need to convert them to hex strings for log (null-terminated buffer). Can somebody advise…
Roman
  • 519
  • 1
  • 5
  • 8
35
votes
7 answers

Vim close buffer but not split window

If I have 2 buffers split horizontally/vertically and want to close one of them, but i don't want to close a window. I want to keep places of split windows are the same as before closing buffer. If I press :bd , the window in which was closed buffer…
RusAlex
  • 8,245
  • 6
  • 36
  • 44
35
votes
5 answers

Possible to calculate MD5 (or other) hash with buffered reads?

I need to calculate checksums of quite large files (gigabytes). This can be accomplished using the following method: private byte[] calcHash(string file) { System.Security.Cryptography.HashAlgorithm ha =…
sindre j
  • 4,404
  • 5
  • 31
  • 32
34
votes
4 answers

Convert nodejs' Buffer to browsers' javascript

I'm converting my code from Node.js to browsers' javascript, but I have a problem with the Buffers in node.js. How can I use them in Javascript? Here's an example: new Buffer("foo", encoding='utf8') I need to transform [66, 6f,…
Fermuch
  • 457
  • 1
  • 6
  • 11
33
votes
1 answer

Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?

char hello[] = "hello world"; std::string str; str.resize(sizeof(hello)-1); memcpy(&str[0], hello, sizeof(hello)-1); This code is undefined behaviour in C++98. Is it legal in C++11?
cubuspl42
  • 7,833
  • 4
  • 41
  • 65
33
votes
4 answers

Why use shm_open?

What's the advantage of doing: shm_open followed a mmap? Why not create a regular file, and then pass that fd to mmap? I can't see the advantage of shm_open - these are just references, are they not? I've read the man of the whole family. It seems…
Trevor
  • 1,858
  • 4
  • 21
  • 28
32
votes
3 answers

Find the exact address of variable Buf

As reference, I'm using the following code: #include #include int main (void) { char buf[100]; // ------> How do I find the address in gdb? printf ("Buffer is at memory location: %08x\n", &buf); strcpy (buf, "some…
Neefra
  • 365
  • 1
  • 4
  • 5
32
votes
13 answers

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in

I don't have any problem on localhost. but when i tested my codes on server, end of every page i see this notice. my code:
AliN11
  • 2,387
  • 1
  • 25
  • 40
32
votes
2 answers

How to append bytes, multi-bytes and buffer to ArrayBuffer in javascript?

Javascript ArrayBuffer or TypedArrays dont have any kind of appendByte(), appendBytes(), or appendBuffer() methods. So if I want to fill an ArrayBuffer one value at a time, how do I do it? var firstVal = 0xAB; // 1 byte var secondVal =…
codneto
  • 2,319
  • 3
  • 24
  • 36
32
votes
7 answers

How to garbage collect a direct buffer in Java

I have a memory leak that I have isolated to incorrectly disposed direct byte buffers. ByteBuffer buff = ByteBuffer.allocateDirect(7777777); The GC collects the objects that harbor these buffers but does not dispose of the buffer itself. If I…
mglmnc
  • 1,400
  • 2
  • 14
  • 15
31
votes
2 answers

Why is writing to a buffer from within a fragment shader disallowed in Metal?

As stated in the Metal Shading Language Guide: Writes to a buffer or a texture are disallowed from a fragment function. I understand that this is the case, but I'm curious as to why. Being able to write to a buffer from within a fragment shader is…
lcmylin
  • 2,552
  • 2
  • 19
  • 31
31
votes
10 answers

A dynamic buffer type in C++?

I'm not exactly a C++ newbie, but I have had little serious dealings with it in the past, so my knowledge of its facilities is rather sketchy. I'm writing a quick proof-of-concept program in C++ and I need a dynamically sizeable buffer of binary…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
30
votes
5 answers

Module '"buffer"' has no exported member 'Blob'

Have anyone been in this situation before ? I run my code with CI/CD after nest build, it gives me error : node_modules/@types/superagent/index.d.ts:23:10 - error TS2305: Module '"buffer"' has no exported member 'Blob'. 23 import { Blob } from…
ninoorta
  • 662
  • 1
  • 5
  • 13
30
votes
5 answers

Uncaught ReferenceError: Buffer is not defined in React

If I add the following lines into my code it throws the following error: import { BIP32Interface } from "bip32"; let node: BIP32Interface = bip32.fromBase58(key); Error: Uncaught ReferenceError: Buffer is not defined I'm using the same package in…
Gyarmati István
  • 503
  • 1
  • 5
  • 8