From: vGhost2000 at gmail dot com Operating system: Linux 2.6.24-23-xen SMP x86_64 PHP version: 5.2.9 PHP Bug Type: ICONV related Bug description: iconv memory leak
Description: ------------ When "Iconv" and "Multibyte String" library classes operate on "SimpleXML" object a memory leak occures while processing "SimpleXML" string objects. If "SimpleXML" string object is converted into an "ordinal" string before the control is being passed to routines from "Iconv" and "Multibyte String" libraries the memory leak doesn't occur. ---------- System Linux 2.6.24-23-xen #1 SMP Mon Jan 26 03:09:12 UTC 2009 x86_64 Apache Version Apache/2.2.8 (Ubuntu) PHP Version 5.2.4-2ubuntu5.5 with Suhosin-Patch Server API Apache 2.0 Handler Zend Engine v2.2.0 phpinfo(): http://79.170.152.11/phpinf.php Reproduce code: --------------- <?php mb_Internal_Encoding('UTF-8'); Header('Content-Type: text/plain; charset=UTF-8'); $sxml = SimpleXML_Load_String('<main><el>some string</el></main>'); For($i = 0; $i < 1000; $i++) { $tmp = IConv('UTF-8', 'UTF-8//TRANSLIT', $sxml->el); # v1 //$tmp = mb_StrToLower($sxml->el); # v2 //$tmp = IConv('UTF-8', 'UTF-8//TRANSLIT', (string)$sxml->el); # v3 //$tmp = mb_StrToLower((string)$sxml->el); # v4 UnSet($tmp); If(!($i % 100)) { Echo $i . ' - ' . Number_Format(Memory_Get_Usage()) . "\n"; } } ?> Expected result: ---------------- In example the first and the second variants demonstrate memory leak. The third and the fourth variants show that some extra conversions help to avoid the memory leak. The results of the script execution. v1: 0 - 103,352 100 - 185,816 200 - 268,232 300 - 350,632 400 - 433,032 500 - 515,432 600 - 646,984 700 - 729,384 800 - 811,800 900 - 894,200 v2: 0 - 103,080 100 - 185,584 200 - 268,016 300 - 350,416 400 - 432,816 500 - 515,216 600 - 646,800 700 - 729,200 800 - 811,600 900 - 894,000 v3: 0 - 103,400 100 - 103,456 200 - 103,456 300 - 103,456 400 - 103,456 500 - 103,456 600 - 103,456 700 - 103,456 800 - 103,456 900 - 103,456 v4: 0 - 103,128 100 - 103,184 200 - 103,184 300 - 103,184 400 - 103,184 500 - 103,184 600 - 103,184 700 - 103,184 800 - 103,184 900 - 103,184 -- Edit bug report at http://bugs.php.net/?id=47669&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47669&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47669&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47669&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47669&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47669&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47669&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47669&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47669&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47669&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47669&r=support Expected behavior: http://bugs.php.net/fix.php?id=47669&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47669&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47669&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47669&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47669&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47669&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47669&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47669&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47669&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47669&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47669&r=mysqlcfg