|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-11-06 17:40 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 08:00:01 2025 UTC |
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