Jump to content

Recommended Posts

Hi guys, I'm having this every day: 

 

 

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 122880 bytes)

 

In my opinion, 256MB of memory shouldn't exhausted so soon, as I only have less than 100 visitor every day...

Could this totally my PHP code faulty ?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/282099-fatal-error-allowed-memory-exhausted/
Share on other sites

either your php script is doing some processing that is taking a huge amount of memory or you have a logic error that is causing a loop to create variables/array data that consumes all available memory.

 

for us to be able to help, you would need to post your script, from the first line (less any database credentials) up through the point where the error is occurring at and if the error is inside of a loop, post the code through to the end of that loop.

Edited by mac_gyver

Hi,

 

My script content dozen of files, I tried to find any leaking by using memory_get_usage() at the start and end, and reload in browser, but every time are the same usage. Is this going to help me find leaking? If so I should try more in every single file.

Here's the full solution in the cleanest possible way:

  1. Create a file called php.ini in the root of your site (if you are using a hosted addon domain, this must be in the subdirectory of that site)
  2. In php.ini, enter a line that says
    memory_limit = 64MB
  3. In your site's .htaccess (being a WordPress blog, I'm assuming there is one), enter the following line
    SetEnv PHPRC /<unix path to the directory where php.ini is>/
    (keep the slashes)
  4. Edit wp-config.php and enter the following line
    define('WP_MEMORY_LIMIT', '64M');
  5. Upload the new files to the server

Here's the full solution in the cleanest possible way:

  • Create a file called php.ini in the root of your site (if you are using a hosted addon domain, this must be in the subdirectory of that site)
  • In php.ini, enter a line that says

    memory_limit = 64MB

  • In your site's .htaccess (being a WordPress blog, I'm assuming there is one), enter the following line

    SetEnv PHPRC /<unix path to the directory where php.ini is>/

    (keep the slashes)

  • Edit wp-config.php and enter the following line

    define('WP_MEMORY_LIMIT', '64M');

  • Upload the new files to the server

There has been no mention of Wordpress in this thread.

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.