From:             tim at digicol dot de
Operating system: Linux (Debian 4.0 x86)
PHP version:      5.2.8
PHP Bug Type:     Date/time related
Bug description:  Memory leak in strtotime()

Description:
------------
With PHP 5.2.8, strtotime() on my Linux box leaks memory; we've 
noticed it because we're using long-running scripts with the PHP CLI. 
In our case, the PHP processes grew to hundreds of MB RAM usage within 
minutes. This is not the case with PHP 5.2.6.

The funny thing is that neither memory_get_usage(false) nor 
memory_get_usage(true) report the actual memory usage; here's a line 
from top:

22728 digicol   25   0  258m 218m 6928 R 75.4 43.4   0:42.91 php

... while the PHP functions report at the same time:

memory_get_usage(false): 1738020
memory_get_usage(true):  1835008

What's also funny is that the default "memory_limit = 128M" setting 
doesn't help: PHP doesn't notice that this much RAM is being 
used and so doesn't kill the script. (But I can trigger the memory 
limit as usual with other PHP scripts, so PHP's memory limit isn't 
entirely broken.)

I tested with an unchanged copy of php.ini-recommended.

My configure string:

'./configure'  '--with-apxs2=/usr/bin/apxs2' '--enable-exif' '--
enable-ftp' '--enable-mbregex' '--enable-mbstring=all' '--enable-
pcntl' '--enable-soap' '--enable-zip' '--with-zlib' '--with-curl' '--
with-freetype-dir=/usr' '--with-gd' '--with-jpeg-dir=/usr' '--with-
ldap' '--with-mysqli' '--with-
oci8=instantclient,/usr/local/lib/instantclient' '--enable-sigchild' 
'--with-png-dir=/usr' '--with-xsl' '--with-mcrypt'

This is Debian Linux 4.0, running in VMware Fusion on an Intel Mac.

Thanks a lot for looking into this, and for the great work on PHP!

Reproduce code:
---------------
<?php

// Run with the PHP CLI on the Linux shell...
// WARNING: If this bug affects you as well, your machine
// might start swapping within just a few seconds!

while (true)
    strtotime('2008-12-16 19:48:27');

?>


Expected result:
----------------
No increase in memory usage.

Actual result:
--------------
Memory usage is increasing dramatically - on my box, the process is 
growing by 100 MB per second...

-- 
Edit bug report at http://bugs.php.net/?id=46889&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46889&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46889&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46889&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46889&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46889&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46889&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46889&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46889&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46889&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46889&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46889&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46889&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46889&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46889&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46889&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46889&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46889&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46889&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46889&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46889&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46889&r=mysqlcfg

Reply via email to