Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-11-2007, 01:51 AM   #1
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Stream buffer size of open file in GNU c library


I have a doubt regarding buffer size provided by file stream. I know that what ever read or write we are doing on a open file ( FILE pointer of fopen()) will act on the buffer provided by GNU c library. I want to know the exact size of the buffer provided by GNU c library. Is there any way to configure this buffer size ?

Thanks in advance.

Old 01-11-2007, 03:06 AM   #2
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,317

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350

Not really sure what the size is. But you can call setvbuf right after fopen so you can set it yourself. See "man setvbuf".

Just looked at stdio.h and it has there is a:

grep "#define _IO_BUFSIZ" /usr/include/*
/usr/include/libio.h:#define _IO_BUFSIZ _G_BUFSIZ

grep "#define _G_BUFSIZ" /usr/include/*
/usr/include/_G_config.h:#define _G_BUFSIZ 8192

So it's 8k. So increasing it with setvbuf is probably a good idea to save kernel calls to speed up things, if you're working with big files.

Last edited by Guttorm; 01-11-2007 at 01:06 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
buffer cache size gsr_kashyap Red Hat 6 09-18-2006 02:15 AM
Data buffer size MarcReing Programming 7 10-21-2004 01:51 PM
Caldera open Linux file size pve Linux - Distributions 2 07-23-2004 01:38 PM
CD write buffer size rch Linux - General 1 09-26-2003 06:50 PM
output file size Linux GNU gcc vs. DJGPP wsimmons Programming 5 01-27-2002 11:20 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration