Page 1 of 1
PHP script execution fails
Posted: Mon Feb 26, 2007 7:19 am
by ashly
Hi,
I am working with php5 and i have a script that should have to be executed as a cron. The main purpose of the script is to send reports as pdf files to different users. The problem is when i generate a number of pdfs, the script fails to complete the process and results in display a page with network error. It is creating around 6 types of pdf files in each execution, each having an average size of 500 KB. The
memory_get_usage() returns the value -51507298 after a function call in
ezpdf library. just before the function call the value for the same was 1967298. Default php.ini setting for
memory_limit is 50 MB. I have set the memory limit in the script to 500 MB.
I am using the library
ezpdf to generate pdf files. Can anyone help me to sort out the problem...?
Thanks in advance
Ashly
Posted: Mon Feb 26, 2007 7:23 am
by Begby
What is the function you are calling? Do you have a code snippet for where this function is called?
Code snippet
Posted: Mon Feb 26, 2007 8:09 am
by ashly
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
--------------
--------------
$prevCol = $row[$key];
while($rowNo < $totalRecords && ($row = pg_fetch_array($rs, $rowNo)))
{
$curCol = $row[$key];
if($curCol == $prevCol)
{
$dataInnerTable[$cntInner++] = array(
"id" => $row['id'] . "/" . $row['sublevel_number'],
"subject" => $row['subject'],
"priority" => $ARR_PRIORITIES[$row['priority']],
"status" => $ARR_STATUS[$row['status']],
"customer_req_date1" => $row['customer_req_date1'],
"date_time1" => $row['date_time1'],
"last_modified_date1" => $row['last_modified_date1'],
"due_date1" => $row['due_date1'],
);
$rowNo++;
}
else
{
break;
}
}
*
$ezPdf -> ezTable($dataInnerTable, $cols, '', $options);
*
--------------
--------------
The memory_get_usage() is called where the * marks are given (it gives the previously mentioned results) and the function i used is in between the * marks.
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Mon Feb 26, 2007 8:33 am
by Begby
I took a gander at the source for that ezpdf function and it a convoluted mess. I am assuming that it is sucking up a ton of resources looping through your data. How many records are you passing it? You might want to either limit the number of records sent to that method at a time or create a workaround to not use that method.
Posted: Mon Feb 26, 2007 11:12 pm
by ashly
Sometimes i have to pass around 1500 records to the ezTable() function.
i have tried to split it and reduced to 500 records.. but still the same problem exists.
Posted: Tue Feb 27, 2007 9:02 am
by feyd
A negative memory usage level means you've gone beyond 2GB. That's way beyond what you should ever be using for a single script.
I don't remember having to cache the entire result set for ezPDF when writing tables.