PHP script execution fails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashly
Forum Newbie
Posts: 9
Joined: Thu Dec 21, 2006 12:14 am

PHP script execution fails

Post 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.

Code: Select all

ini_set("memory_limit", "500M");
I am using the library ezpdf to generate pdf files. Can anyone help me to sort out the problem...?

Thanks in advance
Ashly
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

What is the function you are calling? Do you have a code snippet for where this function is called?
ashly
Forum Newbie
Posts: 9
Joined: Thu Dec 21, 2006 12:14 am

Code snippet

Post by ashly »

feyd | Please use

Code: Select all

,

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

,

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]
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post 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.
ashly
Forum Newbie
Posts: 9
Joined: Thu Dec 21, 2006 12:14 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply