Reply to Re: PHP and memory use

Your name:

Reply:


Posted by NC on 07/20/07 23:51

On Jul 20, 4:21 pm, Alfred Molon <a...@b.c> wrote:
>
> Is there a way to control how much memory a PHP script is using?

Of course. Don't store in variables anything that doesn't need to be
stored. Plan the database and file system interaction accordingly.
Output stuff as soon as it's ready to be output. Don't hesitate to
unset() temporary variables with a lot of data in them as soon as
you're done with them. Avoid resizing images dynamically; resize them
once at the time of upload and serve the resulting thumbnails
statically.

> How to reduce the amount of memory needed?

By design, of course. I would hazard a guess that your problem has
something to do with page content being formed inside a loop and then
dumped in one fell swoop. Something like this:

$content = '';
// ...
while ($record = mysql_fetch_array($result)) {
$content .= "<img src='{$record['imageURL']}'>";
}
// ...
echo $content;

Consider outputting content immediately:

while ($record = mysql_fetch_array($result)) {
echo "<img src='{$record['imageURL']}'>";
}

Another possibility is that your memory issues come from resizing
large images. If that's the case, there's really nothing you can do,
other than limit the size of images you can upload...

Cheers,
NC

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация