http://qs321.pair.com?node_id=655548


in reply to Re: Reading huge file content
in thread Reading huge file content

Are you sure?

I'm fairly certain that your physical RAM limits how much you can read into a single memory segment. That is, if you want to read everything into a single variable, you'll need the physical RAM to do it. Virtual memory can only swap out what you aren't currently accessing.

Am I wrong on this?

--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

Replies are listed 'Best First'.
Re^3: Reading huge file content
by GrandFather (Saint) on Dec 06, 2007 at 23:58 UTC

    Yes, you are wrong. ;)

    Approximately: virtual memory systems give a process a chunk of memory that looks to the process like one large contiguous piece of memory. The process can not tell where or how its process space memory is mapped to physical memory. Indeed that mapping may change from access to access. The OS takes care of ensuring that when a process accesses a chunk of process space memory that the access succeeds if possible. That may entail writing a chunk of physical memory to disk, reading another chunk of disk to get the accessed process memory's contents, then fixing up tables to map process memory address to physical addresses. Hitting on the VM doesn't come cheap!


    Perl is environmentally friendly - it saves trees

      I'd check again.

      Virtual memory will allow your processes to allocate more memory than you have physical ram, provided that you do not need to process it all as a single contiguous chunk.

      But the largest single contiguous chunk (eg. string) that you will be able to allocate will always be somewhat less than your total physical ram.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.