summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_debug.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2009-06-16 13:07:14 +0000
committerAndrey Hristov <andrey@php.net>2009-06-16 13:07:14 +0000
commit10ee06ca48370da3f4858b563d0e0765b4059ee9 (patch)
treeef33b05c58e4d3c7fe211c6d694eb73870228908 /ext/mysqlnd/mysqlnd_debug.c
parent34842709d65b35a9c7b9cee9ba68e116917a15b8 (diff)
downloadphp-git-10ee06ca48370da3f4858b563d0e0765b4059ee9.tar.gz
MFH:
Memory usage optimisation. mysqlnd is not libmysql. mysqlnd does use the Zend allocator, which means that is easier to hit memory_limit if you have big stored (buffered) result sets. Before with libmysql you won't hit memory_limit because libmysql uses libc's allocator and nothing is checked. Now, with mysqlnd the situation is stricter and it is easier to hit memory_limit. We try to optimize for big result sets. If a result set is larger than 10 rows we will start freeing some data to keep memory usage after 10 rows constant. This will help in the cases where a buffered result set is scrolled forward only and just only once, or mysqlnd will need to decode data from the network buffers again - yes, it is a trade-off between CPU time and memory size. The best for big result sets is of course using unbuffered queries - for comparison : 3 Million rows with buffered take at least 180MB, with buffered you will stay at 3MB, and unbuffered will be just 7-8% slower.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_debug.c')
-rw-r--r--ext/mysqlnd/mysqlnd_debug.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index a052748850..2b5724dbe9 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -830,6 +830,9 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
{
DBG_ENTER(mysqlnd_efree_name);
+ if (!ptr) {
+ DBG_VOID_RETURN;
+ }
#ifdef MYSQLND_THREADED
if (MYSQLND_G(thread_id) != tsrm_thread_id()) {
DBG_RETURN(_mysqlnd_pefree(ptr, 1 TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC));