Bug #45644 [Com]: eval() consumes a lot more memory in 64bit system than 32 bit
| From: | chris at willowsconsulting dot ie | Date: | Tue, 17 Nov 2015 14:16:38 +0000 |
| Subject: | Bug #45644 [Com]: eval() consumes a lot more memory in 64bit system than 32 bit | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197298@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=45644&edit=1
ID: 45644
Comment by: chris at willowsconsulting dot ie
Reported by: trepseb at hotmail dot com
Summary: eval() consumes a lot more memory in 64bit system
than 32 bit
Status: Not a bug
Type: Bug
Package: Performance problem
Operating System: Linux fedora
PHP Version: 5.2.6
Assigned To: fb-req-jani
Block user comment: N
Private report: N
New Comment:
I became interested by the eval() behavior recently, and I can confirm that the memory usage gets
higher by the time of the execution.
However it is not really a bug, but the way eval() is fundamentally written:
* it creates a temp file with the code inside (sometimes it is stored in memory)
* it then includes that temp file using a normal include() function
As you can see, the more eval() you do, the more include() it will trigger, resulting in a memory
usage that cannot be freed...
Previous Comments:
------------------------------------------------------------------------
[2008-07-29 20:46:54] jani@php.net
For more info, check bug #41053, bug #40720 which have quite good explanation why this happens.
------------------------------------------------------------------------
[2008-07-29 14:13:09] trepseb at hotmail dot com
Thank you jani. This really was an issue with a debugger extension. I still don't understand
why the "same" debugger does not have a problem in 32 bit systems and why you would see
this as expected behaviour, but it works now. Maybe this is something for the zend people to
analyze. Until now must developer systems are not 64 bit and it's very difficult to get to the
grounds of this on your server alone.
------------------------------------------------------------------------
[2008-07-28 20:17:54] jani@php.net
# uname -a
Linux linux5 2.6.20-1.2944.fc6 #1 SMP Tue Apr 10 17:46:00 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
# USE_ZEND_ALLOC=0 php t.php
start 8208
end 8208
# USE_ZEND_ALLOC=1 php t.php
start 92496
end 223888
# USE_ZEND_ALLOC=1 php -n t.php
start 90952
end 94032
Note the last result. The second is with Xdebug enabled.
Do you by any chance have Xdebug (or any other Zend extension) loaded?
If so, this is quite expected behaviour..
------------------------------------------------------------------------
[2008-07-28 12:18:41] trepseb at hotmail dot com
Description:
------------
We were using eval extensivly for making a dynamic code parser. It used to be all ok till we needed
to use it for more than 30000 iterations. Suddenly our memory limit was reached. We tracked it down
to the underlying code.
Strangely this is only an issue with 64 Bit systems. A PowerMac Dual has this Problem the same as a
8 Core XEON. The INTEL and AMD with 32 bits don't have a Problem, here the script requires no
additional memory with each cycle.
Probably this has to do with some underlying library, but maybe you can figure out which.
Here is a part of my php info
Linux ******** 2.6.23.17-88.fc7 #1 SMP Thu May 15 00:02:29 EDT 2008 x86_64
Build Date May 8 2008 08:38:49
Configure Command './configure' '--build=x86_64-redhat-linux-gnu'
'--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu'
'--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib64' '--libexecdir=/usr/libexec'
'--localstatedir=/var' '--sharedstatedir=/usr/com'
'--mandir=/usr/share/man' '--infodir=/usr/share/info'
'--cache-file=../config.cache' '--with-libdir=lib64'
'--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d'
'--disable-debug' '--with-pic' '--disable-rpath'
'--without-pear' '--with-bz2' '--with-curl'
'--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr'
'--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm'
'--with-gettext' '--with-gmp' '--with-iconv'
'--with-jpeg-dir=/usr' '--with-openssl' '--with-png'
'--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr'
'--with-zlib' '--with-layout=G!
NU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes'
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm'
'--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid'
'--enable-yp' '--enable-wddx' '--with-kerberos'
'--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr'
'--enable-memory-limit' '--enable-shmop' '--enable-calendar'
'--enable-dbx' '--enable-dio' '--without-mime-magic'
'--without-sqlite' '--with-libxml-dir=/usr' '--with-xml'
'--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql'
'--without-gd' '--without-odbc' '--disable-dom'
'--disable-dba' '--without-unixODBC' '--disable-pdo'
'--disable-xmlreader' '--disable-xmlwriter' '--disable-json'
I checked the other eval errors, but they did not have much to do with mine, and they are all stone
old ;).
Reproduce code:
---------------
echo "start ".memory_get_usage()."\n";
$aData['an_anfrage_art'] = '150';
$aData['ega_codes'] = '12|13|15|17|18|23';
for ($i=0;$i<100000;$i++){
eval('$bCondition = !in_array( \'150\' , array(12,13,15,17,18,23));');
}
echo "end ".memory_get_usage();
Expected result:
----------------
start 46592
end 47980
32 bit system. This is the expected result the memory usage is constant with more cycles
Actual result:
--------------
start 78488
end 1710444
64 bit system. Here the memory usage is growing linearly. More cycles make the memory consumption
grow.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45644&edit=1