|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-12-07 08:40 UTC] hanno at hboeck dot de
Description: ------------ APC 3.1.3p1 running with php 5.2.11 produces warnings like this in the error log: [Mon Dec 7 14:35:36 2009] [apc-warning] Unable to allocate memory for pool. in /home/hanno/websites/test.hboeck.de/htdocs/wp-settings.php on line 337. (seems to happen often on Wordpress or Mediawiki pages) Everything seems to work like expected, though this warning pollutes the error log. This does not happen with 3.0.19 (stable) apc or php 5.3.1 (with apc 3.1.3p1). Patchesapc-3.1.14-fix-warnings.diff (last revision 2013-01-09 12:07 UTC by hanno at hboeck dot de)apc-3.1.13-fix-warnings.diff (last revision 2013-01-09 11:51 UTC by hanno at hboeck dot de) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 23:00:01 2025 UTC |
This issue, aside from filling up logs, is a headache when developing. If, as a good developer, you have error reporting displaying everything, then this error will usually create output that is sent before the headers are, which pretty much "breaks" the response as a chain of errors proceed to occur. Therefore, I developed a patch for APC 3.1.7 that I am forced to run with. The patch makes it so that the errors are still written to PHP's standard error log, but don't clobber the HTTP response output. Perhaps this will be useful to someone: diff -u -r APC-3.1.7/apc_bin.c APC-3.1.7-patched/apc_bin.c --- APC-3.1.7/apc_bin.c 2011-01-11 12:06:38.000000000 -0700 +++ APC-3.1.7-patched/apc_bin.c 2011-01-21 18:03:49.000000000 -0700 @@ -703,7 +703,7 @@ apc_bd_alloc_ex(pool_ptr, sizeof(apc_pool) TSRMLS_CC); ctxt.pool = apc_pool_create(APC_UNPOOL, apc_bd_alloc, apc_bd_free, NULL, NULL TSRMLS_CC); /* ideally the pool wouldn't be alloc'd as part of this */ if (!ctxt.pool) { /* TODO need to cleanup */ - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); return NULL; } ctxt.copy = APC_COPY_IN_USER; /* avoid stupid ALLOC_ZVAL calls here, hack */ @@ -854,7 +854,7 @@ for(i = 0; i < bd->num_entries; i++) { ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); if (!ctxt.pool) { /* TODO need to cleanup previous pools */ - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); goto failure; } ep = &bd->entries[i]; diff -u -r APC-3.1.7/apc_main.c APC-3.1.7-patched/apc_main.c --- APC-3.1.7/apc_main.c 2011-01-11 12:06:38.000000000 -0700 +++ APC-3.1.7-patched/apc_main.c 2011-01-21 18:03:35.000000000 -0700 @@ -414,7 +414,7 @@ ctxt.pool = apc_pool_create(APC_MEDIUM_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); if (!ctxt.pool) { - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); return FAILURE; } ctxt.copy = APC_COPY_IN_OPCODE; @@ -539,7 +539,7 @@ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); if (!ctxt.pool) { - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); return old_compile_file(h, type TSRMLS_CC); } ctxt.copy = APC_COPY_OUT_OPCODE; diff -u -r APC-3.1.7/php_apc.c APC-3.1.7-patched/php_apc.c --- APC-3.1.7/php_apc.c 2011-01-11 12:06:38.000000000 -0700 +++ APC-3.1.7-patched/php_apc.c 2011-01-21 18:03:09.000000000 -0700 @@ -578,7 +578,7 @@ ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); if (!ctxt.pool) { - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); return 0; } ctxt.copy = APC_COPY_IN_USER; @@ -819,7 +819,7 @@ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL TSRMLS_CC); if (!ctxt.pool) { - apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + php_log_err("Unable to allocate memory for pool." TSRMLS_CC); RETURN_FALSE; } ctxt.copy = APC_COPY_OUT_USER; By the way, I have provided another patch that addresses a similar issue here: http://pecl.php.net/bugs/bug.php?id=16814PHP 5.3.6 (cli) (built: Mar 19 2011 07:44:03) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans APC 3.1.9 apc.enabled=1 apc.shm_segments=1 apc.shm_size=64M apc.num_files_hint=1024 apc.user_entries_hint=4096 apc.ttl=7200 apc.use_request_time=1 apc.user_ttl=7200 apc.gc_ttl=3600 apc.cache_by_default=1 apc.filters apc.mmap_file_mask=/tmp/apc.XXXXXX apc.file_update_protection=2 apc.enable_cli=0 apc.max_file_size=1M apc.stat=1 apc.stat_ctime=0 apc.canonicalize=0 apc.write_lock=1 apc.report_autofilter=0 apc.rfc1867=1 apc.rfc1867_prefix =upload_ apc.rfc1867_name=APC_UPLOAD_PROGRESS apc.rfc1867_freq=0 apc.rfc1867_ttl=3600 apc.include_once_override=0 apc.lazy_classes=00 apc.lazy_functions=0 apc.coredump_unmap=0 apc.file_md5=0 apc.preload_path Kernel 2.6.21.7-2.fc8xen Server with 5 virtualhosts and max 2 users per virtualhost at once, happens around half an hour after apache reload.