From:             bmorel at ssi dot fr
Operating system: CentOS 5.3
PHP version:      5.2.9
PHP Bug Type:     Regexps related
Bug description:  Memleak in ereg() and eregi() functions

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

Reply via email to