Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 86955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:19:38+00:00 2026-05-10T22:19:38+00:00

Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes).

  • 0

‘Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes)’.

This is the error i get but I am only trying to upload a 1mb image. I have increased the memory limit in php.ini and the execution time. I am trying this on a local MAMP server, on a Mac using firefox. This going to be for an online image gallery. Any ideas? Below is the code:

    ini_set('memory_limit','30M');     if(isset($_POST['submit'])){       if (isset ($_FILES['new_image'])){           $imagename = $_FILES['new_image']['name'];           $source = $_FILES['new_image']['tmp_name'];           $target = 'images/'.$imagename;           move_uploaded_file($source, $target);            $imagepath = $imagename;           //below here for the removed code             $save = 'thumbs/uploads/' . $imagepath; //This is the new file you saving           $file = 'images/' . $imagepath; //This is the original file           $imagesize = getimagesize($file);            list($width, $height) = $imagesize;             unset($imagesize);            if($width>$height)             {                 $modwidth = 150;                  $diff = $width / $modwidth;                 $modheight = $height / $diff;             }else{                 $modheight = 150;                  $diff = $height / $modheight;                 $modwidth = $width / $diff;             }           $tn = imagecreatetruecolor($modwidth, $modheight);            $image = imagecreatefromjpeg($file);            $imagecopy = imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);             imagedestroy($image);           imagedestroy($im);           imagedestroy($imagecopy);           imagedestroy($source);            $imagejpg = imagejpeg($tn, $save, 100);              imagedestroy($tn);           imagedestroy($imagejpg); 

EDIT

This has now been sorted out hopefully. One of my colleagues had a solution all along but neglected to tell me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:19:38+00:00Added an answer on May 10, 2026 at 10:19 pm

    You’re likely loading the image to do some manipulation of it. That causes the image data to be decompressed, which requires a lot of memory for big images (I think it’s about 4 bytes per pixel).

    You can choose to either not process the image, or do your processing outside of PHP – for example by invoking ImageMagick or some other program. It depends a bit on what you’re trying to accomplish.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 136753 bytes)
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 40000 bytes)
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes).
Any ideas why I'm getting .... Fatal error: Allowed memory size of 33554432 bytes
I don't totally understand how all this works, but I'm getting this error: Fatal
I get this error: Fatal error: Call to undefined function () in /home/gmfeedsc/domains/cekdahl.com/public_html/virek/system/application/views/rekommendationer/visa.php on
I get the following compilation error fatal error C1189: #error : ERROR: Use of
The log levels WARN, ERROR and FATAL are pretty clear. But when is something
Do you know any solution to recover from the PHP fatal error : Allowed
I am currently battling this error message by refactoring some of my code: Fatal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.