memory size exausted + strange behavior

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
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

memory size exausted + strange behavior

Post by Skara »

aaaaaahahahaha... erhm.

I'm tring to upload an 8mb file (the very smallest of the files I'll have) and I'm getting...
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2048 bytes) in /var/www/photos/admin/thumbnail.php on line 8

Code: Select all

if(!($src_img = imagecreatefromjpeg($image))) return &quote;Error in imagecreatefromjpeg({$image})&quote;;
Here's the weird part... There's nothing there--no directory, no files. Let me explain. Before that line, there's this code:

Code: Select all

if (!mkdir($uppath.$dir)) err(&quote;Unable to create directory '{$dir}'. Alread uploaded?&quote;);
else {
  //...
  if (!move_uploaded_file($_FILESї'userfile']ї'tmp_name'], $upfile)) err('Unable to move uploaded file.');
  //...
  exec(&quote;tar xfz {$basefile} 2>/var/www/photos/uhoh&quote;);
  //...
  require '../../admin/thumbnail.php';
  if (($handle = opendir('.')) !== false) {
    for ($n=0; false !== ($file = readdir($handle)); $n++) {
      if (preg_match('/.+?\.jpg$/',$file)) {
        chmod($file,0644);
        $res = thumb($dir,$file);
        if ($res !== true) err('Unable to create thumbnail: '.$res);
      }
    }
  }
  //...
Line 8 in thumbnail.php doesn't even get called unless the script enters the correct directory (when thumb() is called). But then nothing is there after the script "finishes." $dir and it's contents dissappear. O.o THAT is weird.

So anyway, how can I fix this bugger?

Edit: O.O Ok.. I know you won't believe this.. It appeared again. As in it's there now. I promise it wasn't there before!!! I ran a script that read all the dirs (that matched a type) and afterwards it was there!! o.o

Ok. Whatever.

SO:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2048 bytes) in /var/www/photos/admin/thumbnail.php on line 8
Edit: oh bugger. I just realized I tar'd the wrong damn files. XD No wonder!! It was trying to use an image that was... *looks* ..well, 669kb, but 2048x1536px. Hahaha. I marvel at my own stupidity sometimes.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

been there, done that. :oops: :cry: :x
Post Reply