kia4567
kia4567

Reputation: 603

MAMP PHP Fatal error: Allowed memory size exhausted

I understand it is a bit harder to diagnose and help when websites are on local servers, but I was hoping that someone else has run into this or has a general idea what and why this is happening? This has to do with wordpress however the bulk of the problem I feel doesn't have anything to do with it but focuses on MAMP and this error I get.

I've now just tried to migrate yet another website to my local server and for some reason it just doesn't work….All I get is a white screen. I've used an error logging technique from http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Logging

/**
 * This will log all errors notices and warnings to a file called debug.log in
 * wp-content (if Apache does not have write permission, you may need to create
 * the file first and set the appropriate permissions (i.e. use 666) )
 */
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

I've also set my DEBUG to true. So I check out this debug.log file I've created and see this error

[03-Sep-2014 22:50:45] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 30720 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/misc.php on line 620

What the heck does that mean?

I went into the location where the "error" is popping up, and just removed that line 620 which looked like this

<input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />

Then there is another error line on the same file, and then again. So as a test I deleted all the content from the page. Then I get ANOTHER error line on the post.php page..

Here's the full debug.log file

[03-Sep-2014 22:50:45] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 30720 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/misc.php on line 620
[03-Sep-2014 22:55:02] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 30720 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/misc.php on line 621
[03-Sep-2014 22:55:30] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 7680 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/misc.php on line 616
[03-Sep-2014 22:55:50] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 7680 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/misc.php on line 618
[03-Sep-2014 22:56:05] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 122880 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/post.php on line 271
[03-Sep-2014 22:56:48] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 122880 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/post.php on line 281
[03-Sep-2014 23:29:12] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 122880 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/post.php on line 271
[03-Sep-2014 23:32:58] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 122880 bytes) in /Applications/MAMP/htdocs/_ANEW/wp-admin/includes/post.php on line 271

I've googled around and it seems that servers give you enough memory and most things shouldn't even use this much space.. so then what might be happening?

I've also looked for the php.ini file but couldn't find it. Do I need to have MAMP PRO?

I'm so confused.So any advice or suggestions would be appreciated.

Upvotes: 4

Views: 13358

Answers (4)

Jodyshop
Jodyshop

Reputation: 664

To increase the memory limit on MAMP, go to your PHP path (maybe vary): /Applications/MAMP/bin/php/php8.0.8/conf/php.ini.

Then increase the value found here:

; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = 128M

After increasing the memory limit value you must restart the MAMP server.

Also, you will need to run this command in your terminal:

php artisan optimize

Thanks

Upvotes: 2

Clark Galgo
Clark Galgo

Reputation: 11

Instead of changing your php.ini file, you can just add this code at the beginning of your php file:

ini_set('memory_limit','32M');

Slowly increase 32M if the error doesn't go away.

This way, you can set memory_limit to a script which needed more memory to execute and not the whole php environment.

Also check your code if your code is consuming more memory than it should, coz this might cause problem in the long run

Upvotes: 0

Gray Ayer
Gray Ayer

Reputation: 1117

Before granting more memory, find out what's using up all your memory. You can start by disabling your plugins by just renaming the plugins folder. Most of the time if you do so, and your site loads up without those warnings, it means you've got some plugins taking up too many resources. If that doesn't work, disable your active theme and let it default to TwentyNineteen or whatever the latest theme from WP is.

Upvotes: 0

Ralf Lang
Ralf Lang

Reputation: 373

Go to the php.ini file and edit memory_limit to a higher value. Start with double the current value and increase until the error goes away (and then add some MB)

Upvotes: 6

Related Questions