ID: 26982
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Debian sid (linux kernel 2.6.0)
PHP Version: 5.0.0b3 (beta3)
New Comment:
It's expected behaviour.
Previous Comments:
------------------------------------------------------------------------
[2004-01-20 15:20:14] [EMAIL PROTECTED]
Description:
------------
I'm using a php script for a large (batch) process (about 4 hours
procesing DB data) and I found the script grows and grows in memory
usage. I've searched and simplify the script to see where was the
problem and I found that a simple php script is loosing memory when
interpolating variables in a string. I don't know if this is exactly a
bug or an expected behavior, but I found it weird and very problematic
on large scripts.
I'm using Debian GNU/Linux sid with kernel 2.6.0. I've tested the
reproduce code in PHP 5.0.0beta3 compiled by myself[1] and with
Debian's PHP 4.3.3 package in the cli and apache module interfaces.
[1] PHP 5.0.0beta3 was compiled with this flags:
'./configure' '--prefix=/usr/local/stow/php5' '--enable-memory-limit'
'--with-openssl' '--with-zlib' '--enable-bcmath--with-bz2'
'--enable-calendar' '--with-curl' '--enable-dba' '--with-db4'
'--with-flatfile' '--with-inifile' '--enable-dbase' '--enable-dbx'
'--enable-dio' '--enable-exif' '--enable-filepro' '--enable-ftp'
'--with-gd' '--with-gettext' '--with-iconv' '--with-mime-magic'
'--with-mysql' '--with-ncurses' '--enable-pcntl' '--with-readline'
'--enable-sockets' '--with-sqlite' '--enable-sysvmsg'
'--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-yp'
'--with-apxs2=/usr/bin/apxs2'
using gcc 3.3.3 (debian package)
Reproduce code:
---------------
<?php
for ($i = 0; $i < 260; $i++)
echo("Memory usage ($i): ".memory_get_usage()."\n");
?>
Expected result:
----------------
Memory usage (<i>): <mem>
where <i> is the iteration step and <mem> is a constant ammount of
memory used by the script. For example:
Memory usage (0): 32224
Memory usage (1): 32224
[snip]
Memory usage (258): 32224
Memory usage (259): 32224
Actual result:
--------------
Memory usage (0): 32224
Memory usage (1): 32272
Memory usage (2): 32296
Memory usage (3): 32320
[snip]
Memory usage (251): 38272
Memory usage (252): 38296
Memory usage (253): 38320
Memory usage (254): 38344
Memory usage (255): 38344
Memory usage (256): 38344
Memory usage (257): 38344
Memory usage (258): 38344
Memory usage (259): 38344
>From 254 and up, the ammount of memory used stays constant (excepting
when the loop is about 1000000 long, in that case the memory
consumption raises a little but then stays constant again).
If I don't use variable interpolation and use the concatenation
operator (.), like this:
echo("Memory usage (".$i."): ".memory_get_usage()."\n");
more memory is used in the second iteration but then stays constant:
Memory usage (0): 31880
Memory usage (1): 31928
Memory usage (2): 31928
Memory usage (3): 31928
Memory usage (4): 31928
[snip]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26982&edit=1