|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-08 09:25 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 13:00:02 2025 UTC |
Description: ------------ There is a memory leak when any script that uses mysql_connect is run. The call to init_available_charsets() (libmysql/charset.c:177) allocates some memory but the call to free_charsets() is never made at the end of the script execution. Reproduce code: --------------- <?php // replace params with your mysql host username and password $db=mysql_connect("127.0.0.1","username","password"); mysql_close($db); ?> Actual result: -------------- valgrind --tool=memcheck --leak-check=yes --show-reachable=yes php test.php Valgrind output: ==20923== 64 bytes in 1 blocks are still reachable in loss record 1 of 1 ==20923== at 0x1B900D20: malloc (vg_replace_malloc.c:131) ==20923== by 0x8091E71: my_malloc (/usr/local/src/php-4.3.10/ext/mysql/libmysql/my_malloc.c:22) ==20923== by 0x809708A: init_dynamic_array (/usr/local/src/php-4.3.10/ext/mysql/libmysql/array.c:35) ==20923== by 0x809949B: init_available_charsets (/usr/local/src/php-4.3.10/ext/mysql/libmysql/charset.c:177) Further notes: The call to my_end() (libmysql/my_init.c) contains a call to free_charsets() but my_end() is never called from anywhere. Php was compiled with: ./configure --with-mysql \ --with-xml \ --with-apache=../apache_1.3.33 \ --enable-track-vars \ --with-gd \ --enable-discard-path \ --enable-bcmath \ --enable-gd-native-tt \ --with-freetype-dir=/usr/local \ --with-png-dir=/usr/local \ --with-jpeg-dir=/usr/local \ --with-zlib=/usr/local ------ -Hexer