Bug #17570 Updated: Memory leak

From: Date: Mon, 17 Jun 2002 23:02:37 +0000
Subject: Bug #17570 Updated: Memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-10966@lists.php.net to get a copy of this message
ID: 17570 Updated by: sniper@php.net Reported By: tzikmund@iccc.cz -Status: Open +Status: Feedback -Bug Type: *Regular Expressions +Bug Type: Regexps related Operating System: Redhat Linux 7.2 PHP Version: 4.1.2 New Comment: Please try with this snapshot: http://snaps.php.net/php4-latest.tar.gz Previous Comments: ------------------------------------------------------------------------ [2002-06-03 06:15:34] tzikmund@iccc.cz I've tried the latest CVS version and it seems the problem is still here. ------------------------------------------------------------------------ [2002-06-03 05:10:41] mfischer@php.net Can you verify against HEAD if this problem is still there? ------------------------------------------------------------------------ [2002-06-03 05:07:07] tzikmund@iccc.cz The problem is still present in 4.2.1 ------------------------------------------------------------------------ [2002-06-03 05:02:51] tzikmund@iccc.cz I'm trying to run PHP in my own multithreaded environment. Memory leaks are critical for my application. I've tried to track the leaks down using memprof and I think I've found a leak in the initialization of globals in standard regex extension. There's original module initialization taken from PHP 4.2.1 sources (ext/standard/reg.c): PHP_MINIT_FUNCTION(regex) { #ifdef ZTS ts_allocate_id(&reg_globals_id, sizeof(php_reg_globals), (ts_allocate_ctor) php_reg_init_globals, NULL); #else php_reg_init_globals(&reg_globals TSRMLS_CC); #endif return SUCCESS; } There's no destructor routine registered for the globals for thread-safe version of PHP. I've tried to correct it writing destructor routine, there's the modified source: static void php_reg_destroy_globals(php_reg_globals *reg_globals TSRMLS_DC) { zend_hash_destroy(&reg_globals->ht_rc); } PHP_MINIT_FUNCTION(regex) { #ifdef ZTS ts_allocate_id(&reg_globals_id, sizeof(php_reg_globals), (ts_allocate_ctor) php_reg_init_globals, (ts_allocate_dtor) php_reg_destroy_globals); #else php_reg_init_globals(&reg_globals TSRMLS_CC); #endif } I'm not sure if my modification is clean, but it seems to solve the leak problem. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17570&edit=1

« previous php.bugs (#10966) next »