httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Stoddard <>
Subject Re: Potential memory leak in /modules/cache/mod_mem_cache.c
Date Wed, 02 Nov 2005 21:54:18 GMT
Ruediger Pluem wrote:
> On 11/02/2005 09:58 PM, Christophe Jaillet wrote:
>>Comments agains httpd-2.1.8-beta
>>In file mod_mem_cache.c (/modules/cache) around line 558, there is a malloc
>>A few lines later, another malloc (buf) is performed.
>>If the second malloc fails, then we have (*obj = NULL) but I don't see
>>anyway to free the memory allocated.
>>I would have imagined something like
>>free (*obj);
>>*obj = NULL;
>>Unless, as a newbie in apache, there is something I don't know about memory
>>management in apache...
> Well spotted.
> mod_mem_cache currently does not get much attention from developer side as we all
> focus on mod_disk_cache which seems to be even faster in most situations than
> mod_mem_cache.

Disagree with your overgeneralization. There are some cases where mod_mem_cache is very effective.

> 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
> 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.


View raw message