Re: Next question about data output...<smile>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Production server says following about version:
PHP Version 5.3.3-7+squeeze16

My local machine is running on XAMPP, with PHP 5.3.5.

Let me try out the memory_get_usage() [1] as well to see if can find out how much memory is being used up, when, and by what part of process.

FWIW, here are the 3 pieces of exact code:

//requesting page:
if (isset($_GET["id"])) {
require("../imageManipulation.php");
require("../template.php");
$templ = new template  ($_GET["id"]);
$templ->renderTemplate();
}//end of checking for querystring ID
exit;

//renderTemplate function in template class, inside template.php
public function renderTemplate($sDisposition="inline") {
if ($this->iID>0) {
$im = new image_manipulation;
$im->mysqliObj = $this->mysqliObj;
$imgOut = $im->dbGetImage("tbl_budget_templates", "b_image", $this->iID);
if (!(is_null($imgOut))) {
 imagepng($imgOut, $this->sTempPath . "temp.png");
$sSize = strval(filesize($this->sTempPath . "temp.png"));
unlink($this->sTempPath . "temp.png");
header('HTTP/1.1 200 OK', True, 200);
header('Content-Type: image/png');
header('Content-Disposition: ' . $sDisposition . '; filename="template.png"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $sSize);
imagepng($imgOut);
imagedestroy($imgOut);
} else {
echo NULL;
}//end of checking if $imgOut != NULL
}//end of checking if iID>0
}//end of renderTemplate function

//and, dbGetImage function from image_manipulation class-imageManipulation.php
function dbGetImage($sTableName, $sField, $iID) {
if (!is_null($this->mysqliObj)) {
$sSQL = sprintf("select %s from %s where id = %s;", $sField, $sTableName, $iID);
$stmnt = $this->mysqliObj->prepare($sSQL);
$stmnt->execute(); //think this is command/action triggering issue
$stmnt->bind_result($bOut);
$stmnt->fetch();
$stmnt->close();
$imgOut = imagecreatefromstring($bOut);
unset($bOut);
return $imgOut;
imagedestroy($imgOut);
} else {
return NULL;
}
}//end of dbGetImage function

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Sascha Meyer" <harlequin2@xxxxxx>
To: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
Sent: Friday, August 16, 2013 8:57 AM
Subject: Aw:  Next question about data output...<smile>


Good morning Jacob,

could you check if memory has been eaten up before the mysqli_statement is executed? memory_get_usage() [1] could help in that case. Are you using different PHP versions on your local dev machine and on the production server?

Best regards,

Sascha

[1] http://php.net/manual/en/function.memory-get-usage.php

Gesendet: Freitag, 16. August 2013 um 08:42 Uhr
Von: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
An: php-windows@xxxxxxxxxxxxx
Betreff:  Next question about data output...<smile>

On my development, windows machine, the memory_limit iniValue is set to 128M, and on the production server - think linux box, it's set to 1280M, but, the bit of script to render an image from database as image resource to browser, works fine on my machine, but, on server, the following error occurs: PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried to allocate 4294967296

According to server log, it seems to be happening on the line where the mysqli_statement tries to execute the query to retrieve a longblob value of 2.1Mb, but anyway.

I am making sure try to destroy any image resources, etc., am closing statement object after executing it, etc. - and there aren't really any recursive loops being executed, but, just a page instantiating an instance of a wrapper class, which then refers to the imageManipulation object, to then pull the images data out of the DB - thoughts?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'




--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux