Re: fopen and memory usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26Sep2007 13:58, aragonx@xxxxxxxxxx <aragonx@xxxxxxxxxx> wrote:
| Okay, so I use fopen and it gives me a stream.  Now when I call fread (say
| for 100K) on my large file (2G) it will try to read the first 64K
| regardless of size and populate *ptr.

Yes. It will read a chunk of the data into the buffer. For a regular
file it will usually be the whole 64kb. For some other things it may be
less (eg a terminal).

| If size is larger than 64K (100K
| here) it will then read another 64K?

After you, the programmer, have consumed the data currently in the
buffer, yes. If you call fread (or scanf etc) with data in the buffer,
that data will be used to satisfy your reuqest. If more is needed, more
is read from the file into the (now empty) buffer).

| Does it use the same buffer space
| (effectively only using 64K)

Yes.

| and is that buffer space outside the memory
| footprint of my application?

No. fopen uses stdin, and that is a library inside your app.
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Early to bed and early to rise makes a man healthy and wealthy with bags
under his eyes. - Dave Cochran, <cochran@xxxxxxxxxxxxx>

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux