Well, that's still just going slower than swapping.
The reason loading things into memory is nice is that:
- in the common case, you don't need to do anything else.
- if the machine is low on memory, it can page things out just about as
easily as you could write things to a file anyway.
So don't worry too much about low-memory situations. Yes, there are cases
where it's better to keep things in files and simply not have a big
working set AT ALL, but if you keep something in a file and the file data
is still part of the working set (ie you read it several times, but at the
beginning and the end), that really isn't any better than having it in
memory.
So the time to try to optimize memory usage is really only for "streaming
behaviour" - where you need to touch something only once. Then the best
option is to actually use a pipe and re-use the memory, but if you have
file data, you can use things like fadvise(DONTNEED).
I suspect you had a bug somewhere. It could be a bug in stdio, but I doubt
it.
You do realize that the correct way to check "feof()" is only _after_
fread() returns 0?
Stdio ferror/feof is horrible to use corrrectly, and few people get it
right. Mostly because it's such a crap interface thanks to being "easy"
to use and thus hiding all the error handling details on purpose.
Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html