1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Where do i change the memory limit on this php script?

Discussion in 'PHP & Perl' started by hell0, Dec 24, 2008.

  1. hell0

    hell0 BANNED BANNED

    Joined:
    Aug 6, 2008
    Messages:
    202
    Likes Received:
    111
    View attachment php file.zip

    I was running this script,its a comment submitter from the forum


    while running,it said memory of x bytes exceecded for .php

    the line i am looking for is:

    something like ...

    memory_limit = 16M

    i want to change it to something like ...

    memory_limit = 10000000M

    though i used the search function,couldnt find it in the file

    do I need a different file to edit?
     
  2. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    The memory limit for php is defined by the servers "php.ini" file. If you are not running a VPS (Virtual Private Server) or a Dedicated Server you probably dont have access to edit the php.ini file.

    If you do have access to edit the php.ini file it typically must be done from the shell, you will need a application such as "putty" to connect to the command prompt of the server on a root level.

    I will not go into details on how to edit the php.ini file, because honestly if you are unsure of how to access the shell and the php.ini file, then you should probably not be touching it. Ask your hosting provider to make this change.

    If you are on a shared hosting environment and do not have access to php.ini you can try adding the following line to your root .htaccess file:

    php_value memory_limit 24M

    Change the "24M" to the memory limit you would like...

    However, if a script is timing out due to using all the memory there is typically a problem with the script itself. I would be hesitant about allowing PHP to use 10000000M of memory to run a script.

    If you would like to know more details about why its a bad ideato make the memory limit that high, please do not hesitate to ask.
     
  3. yeti_racer

    yeti_racer Junior Member Premium Member

    Joined:
    Dec 3, 2008
    Messages:
    192
    Likes Received:
    87
    Location:
    Hick Ville
    drdankmendez got you right on with the php memory limit in your .htaccess file. Even though most of my sites are on a VPS, I use that method anyway so I can control it on a per site basis. Another thing you may consider adding since you are running into limits is up the maximum execution time too. The number is the time in seconds. You can also add it to your .htaccess file in most cases:
    Code:
    php_value memory_limit 24M
    php_value max_execution_time 60
     
  4. hell0

    hell0 BANNED BANNED

    Joined:
    Aug 6, 2008
    Messages:
    202
    Likes Received:
    111
    ok thanks guys,will forward the thread to someone who might understand a bit more :)

    as i dont have the ht access file