From:
Operating system: Linux 2.6.32 x86_64 CentOS 6.2
PHP version: 5.3.9
Package: I18N and L10N related
Bug Type: Bug
Bug description:Memory leak in IntlDateFormatter constructor
Description:
------------
Each time I create a new IntlDateFormatter instance, PHP 5.3.9 leaks
memory. You
can see in "top" that the RES column (resident size) keeps growing as long
as the
script is running; up to more than 500 MB for my example. (By the way,
memory_get_usage() and the PHP memory limit don't report or act on this.)
I've noticed this because we're using long-running scripts with the
PHP CLI - they eventually die when too much memory is used. This happens to
me
with older 5.3.x versions as well.
I tested with PHP 5.3.9 built with "./configure --enable-intl" on 64bit
CentOS
6.2, running in VMware Fusion on my Mac.
Thanks for looking into this, and for the great work on PHP!
Test script:
---------------
<?php
printf("Run 'top -p %s' in another shell to watch memory usage grow...\n",
posix_getpid());
for ($i = 1; $i < 500000; $i++)
{
$fmt = new IntlDateFormatter
(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE
);
}
?>
Expected result:
----------------
[digicol@dcxcentos6vm ~]$ /usr/local/src/php-5.3.9/sapi/cli/php leak.php
Run 'top -p 7211' in another shell to watch memory usage grow...
[digicol@dcxcentos6vm ~]$ top -p 7211
top - 00:13:05 up 12:37, 3 users, load average: 0.34, 0.26, 0.34
Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
Cpu(s): 10.1%us, 3.7%sy, 0.0%ni, 79.7%id, 6.1%wa, 0.1%hi, 0.3%si,
0.0%st
Mem: 2054984k total, 1515064k used, 539920k free, 111760k buffers
Swap: 511992k total, 511992k used, 0k free, 121912k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7211 digicol 20 0 406m 21m 10m S 0.0 1.1 0:00.06 php
Actual result:
--------------
[digicol@dcxcentos6vm ~]$ /usr/local/src/php-5.3.9/sapi/cli/php leak.php
Run 'top -p 7211' in another shell to watch memory usage grow...
[digicol@dcxcentos6vm ~]$ top -p 7211
top - 00:01:18 up 12:26, 3 users, load average: 0.95, 0.65, 0.50
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
Cpu(s): 96.0%us, 3.3%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.3%hi, 0.3%si,
0.0%st
Mem: 2054984k total, 1985784k used, 69200k free, 68784k buffers
Swap: 511992k total, 511860k used, 132k free, 122068k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7211 digicol 20 0 908m 524m 10m R 97.9 26.2 1:15.58 php
--
Edit bug report at https://bugs.php.net/bug.php?id=60785&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60785&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60785&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60785&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60785&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60785&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60785&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60785&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60785&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60785&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60785&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60785&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60785&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60785&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60785&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60785&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60785&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60785&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60785&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60785&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60785&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60785&r=mysqlcfg