"yezi" <ye*****@hotmai l.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
If the file is very huge, but it is needed to be read in the memory,
how to manage the memory,? Thanks for any comment.
Determine the file's size (can be done by opening it
and reading, counting bytes until eof) then allocate
that much memory, and read it in. If the memory allocation
fails, then the whole file won't fit in memory. In that case
you can read what part will fit, then when done with it, read a
different sufficiently small part of the file into that same
memory. Repeat as necessary. (this is known as 'paging', and
is done automatically on systems which feature 'virtual' memory.)
-Mike