php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40172 date() function memory leak
Submitted: 2007-01-19 16:52 UTC Modified: 2007-12-16 01:00 UTC
Votes:6
Avg. Score:3.8 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: diogo86 at gmail dot com Assigned: derick (profile)
Status: No Feedback Package: Performance problem
PHP Version: 5.2.0 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: diogo86 at gmail dot com
New email:
PHP Version: OS:

 

 [2007-01-19 16:52 UTC] diogo86 at gmail dot com
Description:
------------
The date() function keep consuming memory each time it's called even if it's not assigned to any variable.

Reproduce code:
---------------
<?php
for($i=0; $i<10000; $i++)
   date('d/m/Y H:i:s');

echo memory_get_usage();
?>

Expected result:
----------------
Something about 46436 bytes of memory usage just like when I call this statement inside that loop:

$str = strtoupper($_SERVER['PHP_SELF']);

Actual result:
--------------
5485532 bytes of memory usage.


----
Debian Linux 2.6.15-1-486

PHP 5.2.0-8 (cli) (built: Dec 17 2006 20:03:51)

[PHP Modules]
bcmath
bz2
calendar
ctype
date
dba
dom
exif
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mime_magic
ncurses
openssl
pcntl
pcre
PDO
pdo_pgsql
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-19 17:03 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

Cannot reproduce.
 [2007-01-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-09-25 18:34 UTC] travis at pause dot ca
I'm experiencing the same issue: date() increases memory usage (for us) by about 17-20kb each time it's called. We're running Redhat Enterprise on our server with PHP 5.2.4. We've also experienced the problem on Windows XP with PHP 5.2.3.

Interestingly gmdate() is not affected by the issue, leading me to think it was a problem related somehow to the timezone file.

After a little investigation in that direction we found a fix. Simply specify date.timezone in your php.ini file and no more memory leak for date(). 

eg:
date.timezone = America/Toronto

So this bug can be replicated, it does exist (at least in the versions mentioned above), but there is a workaround until the leak is fixed (if it hasn't been in CVS already).

Cheers!
 [2007-10-09 16:43 UTC] derick@php.net
I'll investigate - it might just be caching though.
 [2007-12-08 11:49 UTC] derick@php.net
I still can't reproduce this, not even with an empty php.ini file, on any PHP version between 5.2.1 and 5.3.0-dev.
 [2007-12-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-04-02 22:14 UTC] jon at fantasybookinc dot com
Running php 5.2 on a debian box, experiencing same issue with date() memory leakage.
 [2008-12-29 11:31 UTC] dominique dot fournier at grenoble dot cnrs dot fr
Debian Box Etch with PHP 5.2 continues with this problem (with an empty or complete php.ini file). 
With ini_set ("date.timezone", "America/Toronto"); in php code, the problem is solved.
Debian version :
php5-common    5.2.0-8+etch13
 [2009-03-26 13:40 UTC] james dot haight at gmail dot com
Confirming that this issue exists in 2.6.27.9-159.fc10.x86_64 as 
well, version that comes with recent Fedora 64bit. The above 
workaround works there as well,
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Oct 05 06:05:53 2022 UTC