Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60374 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70206 invoked from network); 30 Apr 2012 09:38:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2012 09:38:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=uwe@thetaphi.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=uwe@thetaphi.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain thetaphi.de designates 188.138.97.18 as permitted sender) X-PHP-List-Original-Sender: uwe@thetaphi.de X-Host-Fingerprint: 188.138.97.18 serv1.sd-datasolutions.de Linux 2.6 Received: from [188.138.97.18] ([188.138.97.18:39719] helo=mail.sd-datasolutions.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/D9-13197-1BD5E9F4 for ; Mon, 30 Apr 2012 05:38:58 -0400 Received: from VEGA (port-92-196-65-14.dynamic.qsc.de [92.196.65.14]) by mail.sd-datasolutions.de (Postfix) with ESMTPSA id 037C614AA006; Mon, 30 Apr 2012 09:38:54 +0000 (UTC) To: "'Pierre Joye'" , "'Uwe Schindler'" Cc: "'Larry Garfield'" , References: <4F9E2173.50005@garfieldtech.com> <000e01cd269a$06f15230$14d3f690$@php.net> In-Reply-To: Date: Mon, 30 Apr 2012 11:39:17 +0200 Message-ID: <002701cd26b5$1cd0bb70$56723250$@thetaphi.de> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHSGBh16tjoKJ9vPkoJpKVM1exOXAG6vPgfAvqifT6Wg4zlgA== Content-Language: de Subject: RE: [PHP-DEV] readfile() memory usage From: uwe@thetaphi.de ("Uwe Schindler") 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