ID:               50480
 Comment by:       lesjno at free dot fr
 Reported By:      lesjno at free dot fr
 Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5.3.1
 New Comment:

Hello jani,
I have a loop to update a database from an excel file. So, for each
excel row I will apply several tests and initializations specified in a
configuration file. The configuration file depend on the user profile.
The eval() function is used, for example, for data initialization : the
configuration file can give a data or a code. For example a specific
date field can take a fix date ("2009-01-01") or can be computed. So,
for example, I can found in a configuration file :
for a user category : $field_init = '2009-01-01' ;
for another user category : $field_init = 'return date("Y-m-d");' ;
I will use the following code :
$data = @eval($field_init) ; if ($data===false) $data=$field_init;
It's only an example but there are a lot of others "eval()" like this
for each excel row treatment.
An excel file can have more than 50000 rows ... so the memory leak is
growing up till the system error ...


Previous Comments:
------------------------------------------------------------------------

[2009-12-16 12:47:05] j...@php.net

Please provide such script that actually has a loop. Simple test
suggested this is just expected and memory does not really grow after
certain point.

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

[2009-12-15 13:27:53] lesjno at free dot fr

Description:
------------
Memory used by the eval() function is not null and can be important (up
to 8Ko) especially if the string is not evaluable.
This memory used can't be released. 
Used in a big loop, the memory used is growing up and I get a memory
error.



Reproduce code:
---------------
$result="";
$memory_used1 = memory_get_usage();
$ch="\$result=22;"; if (@eval($ch)===false) {$result = $ch ;}
$memory_used2 = memory_get_usage();
echo "result=$result ==><b>memory difference =
".($memory_used2-$memory_used1)."<BR></b>\n";

$memory_used1 = memory_get_usage();
$ch="abcdef"; if (@eval($ch)===false) {$result = $ch ;}
$memory_used2 = memory_get_usage();
echo "result=$result ==><b>memory difference =
".($memory_used2-$memory_used1)."<BR></b>\n";

 

Expected result:
----------------
result=22 ==>memory difference = 0
result=abcdef ==>memory difference = 0



Actual result:
--------------
result=22 ==>memory difference = 200
result=abcdef ==>memory difference = 7480




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


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

Reply via email to