Edit report at http://bugs.php.net/bug.php?id=53669&edit=1

 ID:                 53669
 Comment by:         jeffwhiting at hotmail dot com
 Reported by:        jille at hexon dot cx
 Summary:            PHP does not return memory to system
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Linux 2.6.29.2-smp
 PHP Version:        5.3.4
 Block user comment: N
 Private report:     N

 New Comment:

This seems like a big problem.  We are running into the same thing in
our production environment.  We have multiple apache servers and the
memory usage continues to go up just like in the example script.  We are
forced to set MaxChildRequests to 10 to prevent out of memory
conditions.  Running top before the script, the apache/php process is
taking up 13m.  After running the script it says 60m.  Assume you are
running apache with 100 child workers and php is now taking up 6GB. I
understand that for performance reasons it may be nice to keep the 60m
allocated for future use but it would be nice to be able to tune this
parameter.  We would gladly pay the performance penalty of
allocating/deallocating the memory rather than have large allocated and
unused memory.   



However doing something like this (without circular references) works
great and always frees up memory:



<?php



for ($i=0; $i < 20; $i++)

        $s = str_pad("", 1024 * 1024 * $60);



?>


Previous Comments:
------------------------------------------------------------------------
[2011-01-06 15:14:17] jille at hexon dot cx

Description:
------------
The script shows a huge difference in memory used by PHP and memory
claimed by the process. The memory is only returned to the system by
exiting the process.

A simple function that would return the unused memory to the kernel
would be a great solution.



Disabling gc will only make it worse.

Test script:
---------------
<?php

        gc_enable();

        for($i = 0; 1000000 > $i; $i++) {

                $x = new stdClass();

                $x->y = new stdClass();

                $x->y->x = $x;

                $x->meuk = str_repeat('x', 10000);

        }

        gc_collect_cycles();

        var_dump(memory_get_usage(false));

        var_dump(memory_get_usage(true));

?>



Expected result:
----------------
The usage numbers lying closer to eachother.

Actual result:
--------------
int(1816820)

int(25427968)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53669&edit=1

Reply via email to