#42158 [NEW]: SimpleXMLElement as parameter for preg_match leads to memory leak
| From: | chabrol at vfnm dot de | Date: | Tue, 31 Jul 2007 13:13:45 +0000 |
| Subject: | #42158 [NEW]: SimpleXMLElement as parameter for preg_match leads to memory leak | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-115600@lists.php.net to get a copy of this message | ||
From: chabrol at vfnm dot de
Operating system: Linux
PHP version: 5CVS-2007-07-31 (snap)
PHP Bug Type: PCRE related
Bug description: SimpleXMLElement as parameter for preg_match leads to memory leak
Description:
------------
If you use a SimpleXMLElement as parameter for preg_match or
preg_match_all, memory is lost.
P.S.: If you cast the parameter explicit with (string)$xml->name memory
usage doesn't increase. So i suppose it's an problem related to internal
casting.
Reproduce code:
---------------
<?php
$xml = simplexml_load_string("<root><name>foo</name></root>");
for ($i=1; $i<=20; $i++) {
preg_match("/bar/", $xml->name);
// or preg_match_all("/bar/", $xml->name, $matches);
echo "Memory usage after $i iterations: " . memory_get_usage() . "\n";
}
?>
Expected result:
----------------
I would expect an more or less equal memory usage.
Actual result:
--------------
Memory usage is constantly increasing until hitting configured memory
limit
--
Edit bug report at http://bugs.php.net/?id=42158&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42158&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42158&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42158&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42158&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42158&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42158&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42158&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42158&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42158&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42158&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42158&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42158&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42158&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42158&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42158&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42158&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42158&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42158&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42158&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42158&r=mysqlcfg