From:             sasha at integrate dot ru
Operating system: Linux
PHP version:      5.2.5
PHP Bug Type:     Arrays related
Bug description:  Memory leak in array_push operation

Description:
------------
Sorry for my english

php with curl, dbase, dom, gd2, mbstring,pgsql, simplexml,soap,sockets 

It running under eAccelerator, but when I turn it off, the result is just
the same.

actually we use only pgsql. we get request (rather big - more than 3000
rows in result) making array of objects and then trying to convert each
object into html string. converted string (each about 2 Kb length) have
been pushed into array
very soon memory usage growing to 64 Mb and script is crushed
This problem is solved by method refact

        protected function _refact($arr)
        {
        $myarr=array();
        while(!empty($arr)) $myarr[]=array_shift($arr);
        
        return ($myarr);
        }

I call this function after 75, 150, 300 etc iterations, but calling this
function reduce performance. Is that behaviour (I mean memory usage
growing) normal?  

Reproduce code:
---------------
Normal script (crushed)

http://ver.web.integrate.ru/test1.php

Cheated script (with refact method)
http://ver.web.integrate.ru/test1.php


Each script reports tht Init memory (Memory at the begin), how much
objects it proceeds (Now showing), iteration counter (Cicling iteration),
current memry usage (current memory usage) and length of string we pushed
into array (string_length). 

Cheated script (in red hrs) show also the length of array we throw to
refact method


Expected result:
----------------
I guess that the memory usage won't grow while running this script because
the array of objects poped every turn, and the volume of each element of
this array more than the volume of elements of the result array 

Actual result:
--------------
U can see it on url I submit

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

Reply via email to