apcu
apcu copied to clipboard
apc.php request too much memory exceeding php memory_limit
When cached 1500000 entries apc.php request more then 1500mb at execution.
Issue is apcu_cache_info.
FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 402653184 bytes exhausted (tried to allocate 20480 bytes) in apcu.php on line 190"
if set php memory_limit 1600mb or if set $limited = true it works.
I have the same problem
For me the solution to this was putting this at the top of apc.php (after the <?php line obvs): ini_set('memory_limit','256M');
The amount should be bigger than the size that's failing, so probably 512M for you. I'm guessing 2x the apc.shm_size would work, so I was going to write a thing that got that and set the limit appropriately, but haven't done that yet.
Chris
It seems like https://www.php.net/apcu_cache_info should instead be called with $limited = true
in apc.php when the request isn't for the OB_USER_CACHE table.
By default, apcu_cache_info() returns an array corresponding to each entry
// operation constants
define('OB_HOST_STATS',1);
define('OB_USER_CACHE',2);
define('OB_VERSION_CHECK',3);
// ...
// check validity of input variables
$vardom=array(
'OB' => '/^\d+$/', // operational mode switch
// ...
if (empty($MYREQUEST['OB'])) $MYREQUEST['OB']=OB_HOST_STATS;