Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Delphi For PHP > Installation and Configuration
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

Installation and Configuration Need help installing Delphi for PHP? Having trouble configuring it? Post your questions here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 9th January 2009, 13:31
mec's Avatar
mec mec is offline
D4PHP User
 
Join Date: Jun 2008
Posts: 23
mec is on a distinguished road
Default IDE out of memory at 8192 Bytes

Hi, next prob:

I have to create image preview files using imagecreatetruecolor (imagecreate)and imagecopyresampled (imagecopyresized).

I receive the error message:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes)

Is there any way to enable the IDE (or the PHP listener or anything else) to allocate more memory?

Here's the code of my converting function:

Code:
function PhotoGetPreview($phoId, $suffix, $thumbWidth = 150, $thumbHeight = 100)
{
   $photoFile = PHOTO_PATH . $phoId . "_." . $suffix;
   if(file_exists($photoFile))
   {
      $size = getimagesize($photoFile);
      $width = $size[0];
      $height = $size[1];

      $ratioThumb = $thumbWidth / $thumbHeight;
      $ratioPhoto = $width / $height;

      if($ratioThumb <= 1)
      {
         if($ratioPhoto > 1)
            $thumbHeight = intval($height * $thumbWidth / $width);
         else
            $thumbWidth = intval($width * $thumbHeight / $height);
      }
      else
      {
         if($ratioPhoto > 1)
            $thumbWidth = intval($width * $thumbHeight / $height);
         else
            $thumbHeight = intval($height * $thumbWidth / $width);
      }

      $thumbFile = PHOTO_PATH . $phoId . "_thumb_" . $thumbWidth . "x" . $thumbHeight . "." . $suffix;

      if(!file_exists($thumbFile))
      {
         define("GIF", 1);
         define("JPG", 2);
         define("PNG", 3);
         $type = $size[2];

         switch($type)
         {
            case GIF:
               $oldPhoto = imagecreatefromgif($photoFile);
               break;
            case JPG:
               $oldPhoto = imagecreatefromjpeg($photoFile);
               break;
            case PNG:
               $oldPhoto = imagecreatefrompng($photoFile);
               break;
            default:
               return false;
         }

         $newPhoto = imagecreatetruecolor($thumbWidth, $thumbHeight);
         imagecopyresized($newPhoto, $oldPhoto, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $width, $height);
         imagedestroy($oldPhoto);
         switch($type)
         {
            case GIF:
               imagegif($newPhoto, $thumbFile);
            case JPG:
               imagejpeg($newPhoto, $thumbFile);
            case PNG:
               imagepng($newPhoto, $thumbFile);
         }
         imagedestroy($newPhoto);
      }
   }
   return $thumbFile;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 9th January 2009, 13:51
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,274
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

New error ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 9th January 2009, 13:55
mec's Avatar
mec mec is offline
D4PHP User
 
Join Date: Jun 2008
Posts: 23
mec is on a distinguished road
Default

The whole D4PHP is a big error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 9th January 2009, 14:00
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,274
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

that is just how the link rewrites

That link gives you the answer... and it isn't d4php's problem it's a feature of the php setup, designed for server hosts to control how much resource usage is allowed.

Actually you need to set it to 64 or larger by the looks of your error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 9th January 2009, 14:35
mec's Avatar
mec mec is offline
D4PHP User
 
Join Date: Jun 2008
Posts: 23
mec is on a distinguished road
Default

... in heaven the blinds do better ...

I have tried to change the settings in my php.ini located in the...\2.0\php folder. The origin value ther was 320M and I increased it to 640M but the phpinfo still shows 32M. I don't even understand what the "0" between 32 an M means
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 9th January 2009, 15:25
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,274
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

That looks like 320 Meg... Maybe this is a different error than the standard out of memory.

Does it give the line # of where it errors and can you track it down perhaps one very large pic?

Does it error on any pic no matter how small?

Further look at the user notes like:
Quote:
It seems that even a small image can eat up your default memory limit real quick. Config value 'memory_limit' is marked PHP_INI_ALL, so you can change it dynamically using ini_set. Therefore, we can "allocate memory dynamically", to prevent those memory limit exceeded errors.
PHP: imagecreatefromjpeg - Manual

It looks like having unlimited memory actually causes it to crash.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 02:37.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use