#48416 [Com]: Memleak in ereg() and eregi() functions
ID: 48416
Comment by: bmorel at ssi dot fr
Reported By: bmorel at ssi dot fr
Status: Feedback
Bug Type: Regexps related
Operating System: CentOS 5.3
PHP Version: 5.2.9
New Comment:
Sorry, same problem with this snapshot (PHP 5.3.0RC3-dev :
php5.3-200905281630).
The cache seems to be a good explanation, but it this a good idea ?
I have millions of ereg()s done when I parse huge XML files (several
GB), and my memory usage goes too high. I had to replace all my ereg()s
with preg_match()s.
Thanks,
Ben
Previous Comments:
------------------------------------------------------------------------
[2009-05-28 17:30:21] scottmac@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Pretty sure this is due to the regular expression cache we have, each
unique regular expression is cached so we don't keep compiling it but
there is no cap on the number we store.
Can you try a 5.3 snapshot, I think we switched from using ereg to pcre
with 5.3.
------------------------------------------------------------------------
[2009-05-28 16:57:59] bmorel at ssi dot fr
Description:
------------
When repeating an ereg() or eregi() on different patterns, the memory
usage of httpd (or php if executed from the command-line) gets huge
(about 1GB for the example below) for the time the script executes, then
the memory is freed.
During this time, the memory_get_usage() stays normal, and php's memory
limit doesn't trigger.
When repeating the ereg() with the same pattern each time, the memory
usage stays normal; this happens only when repeating with a different
pattern each time.
Verified on CentOS with PHP 5.2.6 & 5.2.9
Verified on Windows XP with PHP 5.2.8
Reproduce code:
---------------
<?php
for ($i=0;$i<1000000;$i++) ereg("$i","test");
?>
Expected result:
----------------
Memory usage staying low.
Actual result:
--------------
Memory usage as shown by "top -d 1" gets huge.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48416&edit=1
Thread (8 messages)