Jump to content

PHP 'Allowed memory size' odd error


richrock

Recommended Posts

I'm having real difficulty with something that should simply work...  :wtf:

 

I've got a script that reads files within a specific folder defined elsewhere.  Then it returns the filenames (image files) to an array.  Relatively simple, you'd think...

 

Here's the process loop :

 

// Read directory for images
        @$dh  = opendir($img_dir);
        while (false !== (@$filename = readdir($dh))) {
            if (($filename == '.') || ($filename == '..') || ($filename == 'Thumbs.db')) {
            } else {
            $files[] = $filename;
            }
        }

 

There is a maximum of 4 images in each folder.  This process will run once per page load.

 

I have checked my php settings:

 

memory_limit   256M

post_max_size   64M

upload_max_filesize 62M (just for good measure).

 

IMHO 256m works for another site I developed which processes up to three images using imagemagick, and I've tested this with a 4mb png file too....

 

Yet I get this error :

 

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 35 bytes) in F:\html\bishopstrings\components\com_content\views\article\tmpl\default.php on line 43

 

This is telling me it's trying to allocate 35bytes when there is 268435456 bytes available...  :o

 

Yet this fails - any help  :confused:

Link to comment
Share on other sites

I'm having real difficulty with something that should simply work...  :wtf:

 

I've got a script that reads files within a specific folder defined elsewhere.  Then it returns the filenames (image files) to an array.  Relatively simple, you'd think...

 

Here's the process loop :

 

// Read directory for images
        @$dh  = opendir($img_dir);
        while (false !== (@$filename = readdir($dh))) {
            if (($filename == '.') || ($filename == '..') || ($filename == 'Thumbs.db')) {
            } else {
            $files[] = $filename;
            }
        }

 

There is a maximum of 4 images in each folder.  This process will run once per page load.

 

I have checked my php settings:

 

memory_limit   256M

post_max_size   64M

upload_max_filesize 62M (just for good measure).

 

IMHO 256m works for another site I developed which processes up to three images using imagemagick, and I've tested this with a 4mb png file too....

 

Yet I get this error :

 

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 35 bytes) in F:\html\bishopstrings\components\com_content\views\article\tmpl\default.php on line 43

 

This is telling me it's trying to allocate 35bytes when there is 268435456 bytes available...  :o

 

Yet this fails - any help  :confused:

 

Maybe an image name/size messes up the loop and makes it run over and over again until it fills up the memory?

Link to comment
Share on other sites

Yes, it's an inifinity loop problem....

 

Line 43 is : $files[] = $filename;

 

I've tried this:

 

$dh  = opendir($img_dir) or die('Not found!');

exit;

 

And it's errored saying it can't find the folder, so I guess it's the wrong filepath.  I'll check that out and go from there.  Cheers!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.