From: irb at redwoodtech dot com Operating system: Windows XP SP2 PHP version: 5.2.3 PHP Bug Type: Date/time related Bug description: Passing string encapsulated in SimpleXMLElement to strtotime causes memory leak
Description: ------------ If a time string is to be read from a SimpleXML object and converted into a unix timestamp then a memory leak occurs if the SimpleXML object is passed directly to strtotime. The memory leak can be stopped by type casting before passing the string to strtotime. For example, change the relevant line in the reproduce code to: $lTime = strtotime ((string) $xml['timestamp']); Reproduce code: --------------- while(true) { $xml = new SimpleXMLElement('<test timestamp="Thu, 5 Jul 2007 16:51:23 GMT"></test>'); echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes : Before STRTOTIME\n"; $lTime = strtotime ($xml['timestamp']); echo 'Current Daemon Memory Usage is ' . memory_get_usage ( ) ." bytes : After STRTOTIME\n"; } Expected result: ---------------- The following is expected. The point being that the memory usage of the application is constant. Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME Current Daemon Memory Usage is 53720 bytes : After STRTOTIME Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME Current Daemon Memory Usage is 53720 bytes : After STRTOTIME Current Daemon Memory Usage is 53720 bytes : Before STRTOTIME Current Daemon Memory Usage is 53720 bytes : After STRTOTIME Actual result: -------------- Memory usage increases over time. Current Daemon Memory Usage is ___94240 bytes : After STRTOTIME Current Daemon Memory Usage is ___94400 bytes : Before STRTOTIME Current Daemon Memory Usage is ___94440 bytes : After STRTOTIME Current Daemon Memory Usage is ___94600 bytes : Before STRTOTIME Current Daemon Memory Usage is ___94640 bytes : After STRTOTIME Current Daemon Memory Usage is ___94800 bytes : Before STRTOTIME Current Daemon Memory Usage is ___94840 bytes : After STRTOTIME -- Edit bug report at http://bugs.php.net/?id=41911&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41911&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41911&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41911&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41911&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41911&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41911&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41911&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41911&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41911&r=support Expected behavior: http://bugs.php.net/fix.php?id=41911&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41911&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41911&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41911&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41911&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41911&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41911&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41911&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41911&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41911&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41911&r=mysqlcfg