Questions tagged [buffering]

Buffering is a process of temporarily storing data while it is being moved from one place to another.

Buffering is a process of temporarily storing data while it is being moved from one place to another. A buffer often adjusts timing by implementing a queue (or FIFO) algorithm in memory, simultaneously writing data into the queue at one rate and reading it at another rate.

Use this tag for programming questions related to data buffer and the process of buffering.

Source: Wikipedia

493 questions
15
votes
4 answers

c++ std::ofstream flush() but not close()

I'm on MacOSX. In the logger part of my application, I'm dumping data to a file. suppose I have a globally declared std::ofstream outFile("log"); and in my logging code I have: outFile << "......." ; outFile.flush(); Now, suppose my code crashes…
anon
  • 41,035
  • 53
  • 197
  • 293
14
votes
5 answers

Win32: Write to file without buffering?

I need to create a new file handle so that any write operations to that handle get written to disk immediately. Extra info: The handle will be the inherited STDOUT of a child process, so I need any output from that process to immediately be written…
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
12
votes
5 answers

Is it safe to disable buffering with stdout and stderr?

Sometimes we put some debug prints in our code this way printf("successfully reached at debug-point 1\n"); some code is here printf("successfully reached at debug-point 2"); After the last printf a segmentation fault occurs. Now in this…
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
12
votes
4 answers

Turn off buffering

Where is the buffer in this following ... and how do I turn it off? I am writing out to stdout in a python program like so: for line in sys.stdin: print line There is some buffering going on here: tail -f data.txt | grep -e APL | python -u…
fodon
  • 4,565
  • 12
  • 44
  • 58
12
votes
3 answers

read huge text file line by line in C++ with buffering

I need to read huge 35G file from disc line by line in C++. Currently I do it the following way: ifstream infile("myfile.txt"); string line; while (true) { if (!getline(infile, line)) break; long linepos = infile.tellg(); …
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
12
votes
3 answers

Python in raw mode stdin print adds spaces

I needed to switch the standard input to non-buffered mode in Python, so that I can read single characters off it. I managed to get it working, but now the standard output is broken: somehow it seems like after the newline character, some space…
K.Steff
  • 2,164
  • 3
  • 19
  • 25
11
votes
2 answers

How to avoid Python fileinput buffering

Possible Duplicate: Setting smaller buffer size for sys.stdin? I have a Python (2.4/2.7) script using fileinput to read from standard input or from files. It's easy to use, and works well except for one case: tail -f log | filter.py The problem…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
11
votes
2 answers

Why is standard output from subprocess (redirected to unbuffered file) being buffered?

From http://docs.python.org/library/functions.html#open The optional bufsize argument specifies the file’s desired buffer size: 0 means unbuffered, 1 means line buffered, any other positive value means use a buffer of (approximately) that…
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
11
votes
4 answers

How to log make output without buffering from stdout and stderr

I am having a problem with logging to output from an automated build. The build is done with a Makefile and the makefile utility. The problem is that normal output like compiler command lines go to stdout and compile errors go to stderr. I want to…
Jeroen Dirks
  • 7,705
  • 12
  • 50
  • 70
11
votes
1 answer

How to disable output buffering in Process.StandardOutput

This question has been asked more than once before, but I have not found a satisfactory answer in any of those discussions. I am launching a command-line process that produces a real-time measurement to STDOUT, producing a new result approximately…
Drew Shafer
  • 4,740
  • 4
  • 30
  • 42
11
votes
2 answers

JTextFields on top of active drawing on JPanel, threading problems

Has anyone ever tried to use Swing to construct a proper multi-buffered rendering environment on top of which Swing user interface elements can be added? In this case I have an animating red rectangle drawn onto a background. The background does…
Mattijs
  • 1,909
  • 3
  • 19
  • 28
10
votes
1 answer

python: reading subprocess output in threads

I have an executable that I call using subprocess.Popen. Then, I intend to feed it some data via stdin using a thread that reads its value from a Queue which will later be populated in another thread. The output should be read using the stdout pipe…
muckl
  • 103
  • 1
  • 1
  • 5
10
votes
1 answer

Buffering log messages in NLog and manually flushes them to target

I am trying to log via the NLog MailTarget. It works just fine, but i wanted to wrap the mailtarget with the BufferedTargetWrapper to buffer the log messages until a predefined codepoint, where i want to manually flush the buffer and send the…
dasheddot
  • 2,936
  • 4
  • 26
  • 33
10
votes
4 answers

Reading multiple Python pickled data at once, buffering and newlines?

to give you context: I have a large file f, several Gigs in size. It contains consecutive pickles of different object that were generated by running for obj in objs: cPickle.dump(obj, f) I want to take advantage of buffering when reading this…
san
  • 4,144
  • 6
  • 32
  • 50
10
votes
11 answers

Buffered reading from stdin using fread in C

I am trying to efficiently read from the stdin by using setvbuf in `_IOFBF~ mode. I am new to buffering. I am looking for working examples. The input begins with two integers (n,k). The next n lines of input contain 1 integer. The aim is to print…
N 1.1
  • 12,418
  • 6
  • 43
  • 61
1 2
3
32 33