Apache Memory Error Page being written to the end of a PHPExcel generated file

Topics: Developer Forum, User Forum
Mar 19, 2010 at 12:18 AM
Edited Mar 19, 2010 at 12:19 AM

I'm generating an Excel file, and it seems that every other time, or just intermittently, this shows up at the bottom of the Excel file contents:

VéøõöŽ[KÐO¶"eĦ×Æ‚§É¾–’âY5z5E‹¥ìy•z9³~ÖÉy¡Èçür;?\´–Lt,ñ\(½
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 admin@example.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error og.</p>
</body></html

Véø€‰ÓijJÙ^»ØˆîpáàŒO¡_A¼ õöŽ[KÐO¶"eĦ×Æ‚§É¾–’âY5z5E‹¥ìy•z9³~ÖÉy¡Èçür;?\´–Lt,ñ\(½

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html><head>

<title>200 OK</title>

</head><body>

<h1>OK</h1>

<p>The server encountered an internal error or

misconfiguration and was unable to complete

your request.</p>

<p>Please contact the server administrator,

admin@example.com and inform them of the time the error occurred,

and anything you might have done that may have

caused the error.</p>

<p>More information about this error may be available

in the server error log.</p>

</body></html>

It seems to be coming from Apache, but just for the sake of information, I am running on a Windows 7 laptop, ZendServer CE, Zend Framework 1.10, PHP 5.3, and my memory limit is set to 128M. When I run this code during the Excel file generation:

error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('memory_limit', '128M');
$bytes = 5000000;
$x = str_repeat('a', $bytes);
...
...
// debugging to look at peak memory usage in PHP ...
$objPHPExcel->setActiveSheetIndex()
      ->setCellValue(
      'A'.($row_name+1),
      " Peak memory usage: " . (number_format(memory_get_peak_usage(true))) . " B\r\n"
);

When it writes that error message to the bottom of the file, the memory usage says 11,534,336 B, but when the file succeeds, the memory usages hits 23,330,816 B Let me know if you have any ideas what might be going on. Thanks for the help,

Dave

Developer
Mar 19, 2010 at 12:59 AM

Hmm... Haven't seen this problem before. Googling on that error message, people suggest looking at the Apache error log?

Mar 19, 2010 at 1:03 AM

Yeah, I tried that, and I don't see anything unusual. I only see messages from when I restarted the server.

Developer
Mar 19, 2010 at 1:17 AM

I have no idea what the problem is. For the record, can you say if this is happening only with big Excel files?

Does the script always terminate after the same period of time? How many seconds? Maybe also check if there are some strange .htaccess files.

Mar 19, 2010 at 3:53 AM

Actually, one thing that seems unique in this situation is that the Excel files are only 7Kb or so by the time it fails. The logic that pulls records from the database using Propel ORM is quite complex, though, and I believe it's using a lot of memory, even if it's only generating a small Excel file.

 

The amount of time it takes to create the bad files and good files is the same. It takes anywhere from 4-10 seconds to generate the Excel file, and sometimes they contain the Apache error page, and sometimes they don't. At first, it seemed to happen exactly every other time, but now I don't believe there is a perfect pattern like that.

 

I will check into the .htaccess files, and if I don't find anything, I am going to have to refactor my Propel query logic. Thanks for your advice,

Dave