Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 20636 invoked from network); 2 Nov 2005 22:55:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Nov 2005 22:55:19 -0000 Received: (qmail 52712 invoked by uid 500); 2 Nov 2005 22:55:17 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 51869 invoked by uid 500); 2 Nov 2005 22:55:14 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 51857 invoked by uid 99); 2 Nov 2005 22:55:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2005 14:55:14 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [204.146.167.214] (HELO Boron.MeepZor.Com) (204.146.167.214) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2005 14:55:08 -0800 Received: from [127.0.0.1] (dmz-firewall [206.199.198.4]) by Boron.MeepZor.Com (8.12.8/8.12.8) with ESMTP id jA2MsNVL025155 for ; Wed, 2 Nov 2005 17:54:44 -0500 Message-ID: <4369439C.2030400@wstoddard.com> Date: Wed, 02 Nov 2005 17:54:20 -0500 From: Bill Stoddard Reply-To: bill@wstoddard.com User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@httpd.apache.org Subject: Re: Potential memory leak in /modules/cache/mod_mem_cache.c References: <43693392.6050002@apache.org> <4369358A.9050306@wstoddard.com> <436940D0.5040708@apache.org> In-Reply-To: <436940D0.5040708@apache.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Ruediger Pluem wrote: > > On 11/02/2005 10:54 PM, Bill Stoddard wrote: > >>Ruediger Pluem wrote: > > > [..cut..] > > >>>Finding calls to malloc and friends in the code of mod_mem_cache is a >>>clear documentation >>>that there is no development care of this code as they should not be >>>used inside of >>>httpd code. Throughout the httpd code memory pools will be used to >>>aquire memory for storing >>>data structures. >> >> >>mod_mem_cache does not use pools to store objects because it is not >>straightforward how to recover pool storage when stale cache objects are >>removed from the cache. For example, if you have 10,000 objects in the >>mem cache and you need to garbage collect 1837 of them, how do you do it >>(and return the memory to the system) if all 10,000 objects are >>allocated out of the same pool? There are ways of doing it, but not >>straigtforward. > > > Ok. You got me :-). I should have taken a closer look at the code before. > I agree that this problem is not straightforward to solve, especially not > for someone who is not that deep into pools like me and who still has a lot > to learn in this area. > > In order to improve my understanding of mod_mem_cache at which I had > a (more) closer look than before I would like to ask some questions: > > For whatever reason I firmly believed that mod_mem_cache has a common cache > via shared memory over all httpd processes. This does not seem to be true, correct? Correct. mod_mem_cache stores objects in the heap (not in shared memory). It can store file contents in heap or it can store open file descriptors. > > But if each httpd process maintains its own local cache, this would mean > that the same object needs to be cached multiple times if clients request > the same object from different httpd processes. This would > > - increase the load on the backend Yes > - increase the thundering herd problem for stale cache entries Yes > - increase memory usage per object as each httpd process does have a local > copy of it in memory. Yes > > Do I see this correct? Yep, you see it correctly. Mod_mem_cache is most interesting to me personally as a benchmark toy. It should be possible to extend mod_mem_cache to cache headers (rather than rebuilding them for each response sent out of the cache), align storage on processor cache-lines and other performance tweaks to serve static pages really really fast (or cache dynamically generated pages until they become stale). You should be able to use mod_mem_cache to explore the static page performance limits of Apache HTTPD 2.0. > > > Regards > > R�diger Bill > > >