SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Allowed Memory Exhausted

    Hi all.

    I have a peculiar problem. When I'm uploading a photo to a website I have which runs on Wordpress on a MySQL database I am getting a "Fatal error memory size exhausted" message. However, it only happens on one PC. It works on other PC's.

    I've tested it on all browsers and on a few different machines both apple and pc. It's always the same result on this one pc.

    What must I change on this pc to make it work?

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    There is a setting in php.ini called "memory_limit" which determines how much memory a script can use, it's probably set lower on the one server
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    There is a setting in php.ini called "memory_limit" which determines how much memory a script can use, it's probably set lower on the one server
    This is a local pc I'm talking about. Not sure if i made that clear. If its working on every other computer I use is it not likely to be a local issue.

    I don't have a php.ini file in the given directory on the server and it says on the upload page the photo upload limit was 8mb. The file I'm testing with is only 2mb.

    Do I still need to create a php.ini file on the server even if this issue is only happening on one of my computers.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Actually, if it's working on every computer except that one, it's.... almost certainly a local issue? That being the definition of local issue and all.

    But let's just rule a few things out. Stop me if I make a mistake here.
    1: You're uploading the same file from multiple computers to a single server running a single script.
    2: The file in question is below 2 MB in size
    3: You are not attempting to upload more than 8 MB in -total- in a single pageload.

    How much memory is the error showing that the script is limited to, and how much is it attempting to allocate?

    (PS: Flagging this for movement to the PHP forum, as the issue appears to be a PHP generated error rather than a DB generated one)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    Actually, if it's working on every computer except that one, it's.... almost certainly a local issue? That being the definition of local issue and all.

    But let's just rule a few things out. Stop me if I make a mistake here.
    1: You're uploading the same file from multiple computers to a single server running a single script.
    2: The file in question is below 2 MB in size
    3: You are not attempting to upload more than 8 MB in -total- in a single pageload.

    How much memory is the error showing that the script is limited to, and how much is it attempting to allocate?

    (PS: Flagging this for movement to the PHP forum, as the issue appears to be a PHP generated error rather than a DB generated one)
    Almost...

    It's ANY photo attempted from the affected PC. I tested on other PC's with 2 of the affected photos and both were 2mb or under.

    I only ever uploaded one at a time so no more than 8mb in one single action.

    So... Single file, single script, single server and it works on all but one PC.

    The allowed memory size is 134217728 and its trying to allocate 19772 in one of the images (which is a 1.9mb photo).

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    What difference in any is there in hardware, OS or web browser between the computers where it works and the one were it doesn't?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    So it's allowed 128 MB for execution and it's capping it out. Sounds like there's a leak somewhere, unless it's trying to load all the pictures in the directory at once.

    Is the page in question a WordPress-provided one, or a custom one?

    (Phoenix and I will come at this from opposite ends, and probably meet somewhere in the middle )
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  8. #8
    SitePoint Zealot
    Join Date
    Oct 2010
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    So it's allowed 128 MB for execution and it's capping it out. Sounds like there's a leak somewhere, unless it's trying to load all the pictures in the directory at once.

    Is the page in question a WordPress-provided one, or a custom one?

    (Phoenix and I will come at this from opposite ends, and probably meet somewhere in the middle )
    Hi there StarLion,

    Yes it is a wordpress standard page, not one I have coded myself. It's media.php which is located in the wp-includes folder of a standard wordpress install in case you're interested. And it's line 258. Here is that chunk of code in case you wanted to see it.

    Code PHP:
     
    256      // Set artificially high because GD uses uncompressed images in memory
    257      @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
    258      $image = imagecreatefromstring( file_get_contents( $file ) );
    259
    260	  if ( !is_resource( $image ) )
    261		return sprintf(__('File “%s” is not an image.'), $file);
    262
    263	    return $image;
    264    }

    SpacePhoenix, I'll try to find out the hardware differences. But it's not my PC that it doesn't work on - it's a client. This is for a website I am developing. I have tested it on 3 of my owm machines (all different configurations and browsers) and he has tested it on both of his (One is a PC and the other is an iMac - it works on the Mac).

    I know he is using Google Chrome - But I have also tested it with chrome so I don't think that's the problem. Both of us use the same (up to date) version.

    That's all of the information I have for now - I will try to get more.

  9. #9
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    So the line right before it is the one that grabs my attention.

    @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );

    have you checked this value (WP_MAX_MEMORY_LIMIT) to make sure its not accidentally set too low?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •