Bug #66091 [Opn->Nab]: Memory leak in DateTime::createFromFormat()
| From: | ab@php.net | Date: | Sat, 05 Apr 2014 17:03:46 +0000 |
| Subject: | Bug #66091 [Opn->Nab]: Memory leak in DateTime::createFromFormat() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185115@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66091&edit=1
ID: 66091
Updated by: ab@php.net
Reported by: lars_teuber at gmx dot de
Summary: Memory leak in DateTime::createFromFormat()
-Status: Open
+Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: Windows/Linux
PHP Version: Irrelevant
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
so marking as nab
Previous Comments:
------------------------------------------------------------------------
[2014-04-05 17:03:04] ab@php.net
But in your code, you just continuously create new objects. It is then logic that the memory is
cluttered up. Try using the return value and then explicitly unset() it.
------------------------------------------------------------------------
[2013-11-13 17:01:03] lars_teuber at gmx dot de
Description:
------------
Hi,
DateTime::createFromFormat() has a memory leak.
Tested with: 5.3.14, 5.4.4, 5.5.3
Best regards
Lars Teuber
Test script:
---------------
<?php
$mem_start = memory_get_usage(true);
echo 'start: ' . $mem_start . '<br>';
$max_iterations = 1000000;
for ($i = 1; $i <= $max_iterations; $i++) {
DateTime::createFromFormat('M/D/Y H:i:s', '2013-11-12 20:00:00');
if (($i % 100000) == 0) {
echo $i . '.: ' . memory_get_usage(true) . '<br>';
}
}
$mem_end = memory_get_usage(true);
echo 'end: ' . $mem_end . '<br>';
echo 'diff end-start: ' . ($mem_end - $mem_start) . '<br>';
?>
Expected result:
----------------
(more or less) constant memory usage
Actual result:
--------------
start: 524288
100000.: 16777216
200000.: 33030144
300000.: 53477376
400000.: 65536000
500000.: 77594624
600000.: 106168320
700000.: 118226944
800000.: 130285568
900000.: 142344192
1000000.: 154140672
end: 154140672
diff end-start: 153616384
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66091&edit=1