Which of FILE* or ifstream has better memory usage?
Posted
by Viet
on Stack Overflow
See other posts from Stack Overflow
or by Viet
Published on 2010-04-30T17:09:01Z
Indexed on
2010/04/30
17:17 UTC
Read the original article
Hit count: 205
I need to read fixed number of bytes from files, whose sizes are around 50MB. To be more precise, read a frame from YUV 4:2:0 CIF/QCIF files (~25KB to ~100KB per frame). Not very huge number but I don't want whole file to be in the memory. I'm using C++, in such a case, which of FILE* or ifstream has better (less/minimal) memory usage? Please kindly advise. Thanks!
EDIT:
I read fixed number of bytes: 25KB or 100KB (depending on QCIF/CIF format). The reading is in binary mode and forward-only. No seeking needed. No writing needed, only reading.
EDIT:
If identifying better of them is hard, which one does not require loading the whole file into memory?
© Stack Overflow or respective owner