Hi,

> mmap may use "normal" memory too, depending on the options (not sure
> which are used exactly with readfile or stream's mmap).

Mmapping of course uses memory, but the memory used here is not from PHP's
memory manager, it's memory that's already used for the O/S cache. The
memory mapping used here does not enforce loading the file contents into O/S
cache; it just gets a virtual address into the O/S cache. If the actual file
contents are not yet in O/S cache, the O/S will hit a page fault and load
the pages into memory. Apache Server uses the same mechanism to serve files.

Maybe the "user confusion" about memory usage comes from that fact (they see
lots of *virtual* memory used by PHP when viewed in top). I know this user
confusion from my work in the Apache Lucene/Solr project, where one option
(used on 64 bit operating systems) is to memory-map the whole Lucene
full-text index. Users then see hundreds of Gigabytes of "virtual memory"
usage in TOP / Windows Task Manager and are afraid of running their machine
out of memory. This is always hard to explain to people that are not used to
the term "virtual memory".

> About php memory usage, one has to use an external tools to actually see
this
> memory usage as it is not managed by the zend memory manager.

Of course...

Thanks,
Uwe


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to