Hi there,
I have a web page written on PHP. The PHP script itself receives the
file uploaded by user, parses it and displays HTML table with the
user data - one table row per item. Let's say that (very simplified) PHP
code in question goes like this
[PHP]echo "<table>";
foreach ($user_data as $key => $item ){
echo "<tr>";
echo "<td> Row no: ".$key."</td>";
echo "<td> user item: ".$item."</td>";
echo "/<tr>";
}
echo "</table>";[/PHP]
i.e. each element of user_data array is echoed enclosed by HTML
tags in some form, and sometimes additional table cells that do not contain user supplied data are echoed as well.
Recently I've found that for large user_data array sizes (~500 rows in my case) I'm running into memory allocation problem - I get the
Fatal error: Allowed memory size of XXX bytes exhausted (tried to allocate YYY bytes) ... message and the script dies.
I understand that the problem is that each (event constant, double quoted string with HTML inisde) string is allocated many times and is not freed properly,
and hence the memory gets exhausted.
What is the best way to handle this problem?
Thanks a lot for your help,
Igor.