apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Toptygin <alex...@freeshell.org>
Subject shared memory question
Date Tue, 13 Dec 2005 02:10:16 GMT

Hi,

I'm writing a module under apache 2.0, and I'd like to share a cache among 
all the worker threads. I think I can use the apr_shm.h stuff to create a 
shared memory segment, and I can use apr_global_mutex.h to serialize 
access to this cache. I don't think APR provides any way to manage 
allocating chunks of the shared memory segment, correct? (i.e. I'd need to 
do my own memory management inside the shmem segment)

Also, there are some dire warnings in the global_mutex documentation about 
efficiency; if every request needs to ba checked in the cache, and added 
if it's not in there, is this likely to have a performance-killing impact?

Maybe I should give up on a global cache and instead do caching in each 
process? In that case, a followup question: since cache entries will be 
created and expired regularly throughout the life of the server, I can't 
see any way to reclaim memory, since current cache entries will still be 
alive inside whatever pool I'm allocating them from. Am I missing 
something? Should I be using libc malloc/free for the cache entries to 
avoid this, or do I still need to do my own memory management for the 
cache?

Any hints greatly appreciated.

 			Alexey

Mime
View raw message