We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Why is nGen File Field using so much memory?

Development and Programming

Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

Been successfully using nGen File Field to populate a Slide Show Pro gallery. But now there’s about 8 or more separate galleries (each containing several photos) I’m getting the following error from the Control Panel when I try to add or edit a gallery.

Fatal error: Out of memory (allocated 66322432) (tried to allocate 17024 bytes) in /home/shakethe/public_html/admin/extensions/fieldtypes/ngen_file_field/ft.ngen_file_field.php on line 842

I can up my memory limit above 64MB with my current hosts without paying big bucks for a dedicated server!

Can someone please help me figure out a way to keep this working under the 64MB limit please?

Thanks!

Moved to Extensions Forum by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Matthew, this is something you’ll need to take up with the author. Moving to the extensions forum.

       
Max Lazar's avatar
Max Lazar
341 posts
16 years ago
Max Lazar's avatar Max Lazar

I think, it because in this moment, nGen tried to create the thumbs for your images. And some of images are too big. You can calculate the memory needs for you image (estimate): Num bytes = Width * Height * Bytes per pixel * Overhead additional info

       
Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

Hi Max - thanks for the pointer. That sounds right.

Can I improve the thumbnail creation from nGen? Or actually turn it off?

Thanks!

       
Max Lazar's avatar
Max Lazar
341 posts
16 years ago
Max Lazar's avatar Max Lazar

Of course the ngenworks can consult you to more better in this topic, just 2c from my side: Or actually turn it off? As I know, is no easy way to turned it of. Only to edit the source.

Can I improve the thumbnail creation from nGen? I make some investigation of this issue for my ext. , so I see 2 ways at this moment: 1. Dynamically allocate need memory source

<?php
function setMemoryForImage( $filename ){
    $imageInfo = getimagesize($filename);
    $MB = 1048576;  // number of bytes in 1M
    $K64 = 65536;    // number of bytes in 64K
    $TWEAKFACTOR = 1.5;  // Or whatever works for you
    $memoryNeeded = round( ( $imageInfo[0] * $imageInfo[1]
                                           * $imageInfo['bits']
                                           * $imageInfo['channels'] / 8
                             + $K64
                           ) * $TWEAKFACTOR
                         );
    //ini_get('memory_limit') only works if compiled with "--enable-memory-limit" also
    //Default memory limit is 8MB so well stick with that.
    //To find out what yours is, view your php.ini file.
    $memoryLimit = 8 * $MB;
    if (function_exists('memory_get_usage') &&
        memory_get_usage() + $memoryNeeded > $memoryLimit)
    {
        $newLimit = $memoryLimitMB + ceil( ( memory_get_usage()
                                            + $memoryNeeded
                                            - $memoryLimit
                                            ) / $MB
                                        );
        ini_set( 'memory_limit', $newLimit . 'M' );
        return true;
    }else
        return false;
    }
}
?>
  1. Check memory needs after upload and delete files which has size more than memory_limit (you can use the code of setMemoryForImage for this with modification)
       
Derek Hogue's avatar
Derek Hogue
317 posts
16 years ago
Derek Hogue's avatar Derek Hogue

Matt – I could be wrong, but the memory-intensive processes of File Field should only happen once - after first installing it and loading up an entry screen which has a field linked to a directory containing a tonne of images. Once the thumbs are created, it’s very fast. From there-on-in, it only has to generate one thumbnail at a time (when new ones are added).

       
Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

Thanks Max!

I’m gonna ngenworks involved.

Cheers,

Matthew

       
MarqueDigital's avatar
MarqueDigital
33 posts
16 years ago
MarqueDigital's avatar MarqueDigital

Did you get any further with this? These errors have crippled the site I am working on.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.