#43206 [Asn->Csd]: date_timezone_get() leaks memory

From: Date: Tue, 08 Jul 2008 18:07:36 +0000
Subject: #43206 [Asn->Csd]: date_timezone_get() leaks memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126401@lists.php.net to get a copy of this message
ID: 43206 Updated by: derick@php.net Reported By: thekid@php.net -Status: Assigned +Status: Closed Bug Type: Date/time related Operating System: Any PHP Version: 5.2.5RC2 Assigned To: derick New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-11-06 17:42:38] thekid@php.net The following patch fixes the problem: == $ cvs diff -u ext/date/ cvs diff: Diffing ext/date Index: ext/date/php_date.c =================================================================== RCS file: /repository/php-src/ext/date/php_date.c,v retrieving revision 1.43.2.45.2.51 diff -u -r1.43.2.45.2.51 php_date.c --- ext/date/php_date.c 12 Jul 2007 18:59:05 -0000 1.43.2.45.2.51 +++ ext/date/php_date.c 6 Nov 2007 17:40:24 -0000 @@ -1613,7 +1613,7 @@ static void date_object_free_storage_timezone(void *object TSRMLS_DC) { php_timezone_obj *intern = (php_timezone_obj *)object; - + timelib_tzinfo_dtor(intern->tz); zend_object_std_dtor(&intern->std TSRMLS_CC); efree(object); } cvs diff: Diffing ext/date/lib cvs diff: Diffing ext/date/tests == Seems it was simply forgotten to free the timezone in DateTimeZone's destructor. Because ->tz is an internal pointer (and not a zval) memory_get_usage() will not report a memory increase, you'll have to use Task Manager / top / ps to see the effect ------------------------------------------------------------------------ [2007-11-06 17:40:00] thekid@php.net Description: ------------ date_timezone_get() leaks memory Reproduce code: --------------- <?php $d= date_create('now'); while(TRUE) { date_timezone_get($d); } ?> Expected result: ---------------- Memory usage stays constant. Actual result: -------------- Memory usage increases. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43206&edit=1

« previous php.bugs (#126401) next »