Bug #67686 [Fbk->NoF]: date_create_from_format memory leak

From: Date: Sun, 15 Nov 2020 04:22:14 +0000
Subject: Bug #67686 [Fbk->NoF]: date_create_from_format memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230363@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67686&edit=1 ID: 67686 Updated by: php-bugs@lists.php.net Reported by: alex at iplenix dot com Summary: date_create_from_format memory leak -Status: Feedback +Status: No Feedback Type: Bug Package: Date/time related Operating System: windows 8.2 and centos 6.5 PHP Version: 5.5.15 Assigned To: cmb Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2020-11-05 15:44:01] cmb@php.net I cannot reproduce this with current PHP-7.3. Does this still happen to you with any of the actively supported PHP versions[1]? [1] <https://www.php.net/supported-versions.php> ------------------------------------------------------------------------ [2014-07-25 19:17:27] alex at iplenix dot com Description: ------------ function date_create_from_format leak memory when returns false. Test script: --------------- <?php define('PHP_ERROR_REPORTING',E_ALL); // Coloca no diretorio do binario e dai todos as indirecoes funcionam chdir( dirname ( __FILE__ ) ); main_teste_memoria(); function iplx_echo_memuse($msg){ $m1=memory_get_usage(); $m2=memory_get_usage(true); echo "$msg php($m1) system($m2)\n"; } function test_date_create_from_format($ts='20140530140000'){ $date = date_create_from_format('d-m-Y H:i:s', $ts, new DateTimeZone('UTC')); // $date = date_create_from_format('Y-m-d H:i:s', $ts, new DateTimeZone('UTC')); // $date = date_create_from_format('YmdHis.u', $ts, new DateTimeZone('UTC')); // $date = date_create_from_format('YmdHis.s', $ts, new DateTimeZone('UTC')); // $date = date_create_from_format('d/m/y H:i:s', $ts, new DateTimeZone('UTC')); $date = date_create_from_format('YmdHis', $ts, new DateTimeZone('UTC')); for($i=0;$i<100;++$i){ $date->modify('+1 minute'); $ts=$date->format('YmdHis'); $date = date_create_from_format('YmdHis', $ts, new DateTimeZone('UTC')); } } function main_teste_memoria(){ $ts = '20140530140000'; $counting = 1; $oldLimit = ini_get("memory_limit"); echo "Current memory limit $oldLimit \n"; ini_set("memory_limit", "1M"); $oldLimit = ini_get("memory_limit"); gc_enable(); // enable memory management echo "Current memory limit $oldLimit \n"; while(true){ iplx_echo_memuse("Before test_date_create_from_format"); test_date_create_from_format($ts); $counting++; iplx_echo_memuse("After test_date_create_from_format"); echo "Executions ($counting) \n"; } } ?> Actual result: -------------- Executing on Windows 8.1, PHP 5.5.15 the result after some seconds is this crash. > php test_date_create_from_format.php ... Executions (8188) Before test_date_create_from_format php(614928) system(1048576) After test_date_create_from_format php(614960) system(1048576) Executions (8189) Before test_date_create_from_format php(614960) system(1048576) PHP Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 524288 bytes) in X:\Iplenix_Fontes\mtx-gateway\gw-www\client-side\BirtechVirtualModem\bin\test_date_create_from_format.php on line 26 ============================================================================== On centos 6.5 64bits, PHP 5.4.29 the result is very similar. $ php test_date_create_from_format.php ... Executions (4090) Before test_date_create_from_format php(692288) system(1048576) After test_date_create_from_format php(692352) system(1048576) Executions (4091) Before test_date_create_from_format php(692352) system(1048576) After test_date_create_from_format php(692416) system(1048576) Executions (4092) Before test_date_create_from_format php(692416) system(1048576) After test_date_create_from_format php(692480) system(1048576) Executions (4093) Before test_date_create_from_format php(692480) system(1048576) PHP Fatal error: Allowed memory size of 1048576 bytes exhausted (tried to allocate 524288 bytes) in /var/iplenix/mtx-gateway/gw-www/client-side/BirtechVirtualModem/bin/test_date_create_from_format.php on line 26 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67686&edit=1

« previous php.bugs (#230363) next »