Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001

    php memory problem

    i was running a php script that grabs data from a site and saves data in a txt file.
    after running the script for few hours it crashed giving the error
    <br />
    <b>Fatal error</b>: Allowed memory size of 8388608 bytes exhausted at (null):0 (tried to allocate 35 bytes) in <b>/home/admin/www/script.php</b> on line <b>3</b

    i have changed the memory_limit from 8M to 16M in /etc/php.ini
    the script works fine now.

    i was wondering if this is a correct way of handing this problem?

    i have been advised not to play around with the php memory settings.

    anyone ?


  2. #2
    Join Date
    Nov 2001
    This will solve the problem until your text file gets larger ( I assume you are reading the entire file into the script? which would explain why it worked at first )

    you might want to think about breaking it up into multiple files or use a database.

  3. #3
    Join Date
    Aug 2001
    do you think saving the output of the script in a mysql database will help?

  4. #4
    First be sure you read and understand the php script.

    That was a bad way of handeling it IMO.

    Using multiple files might be an option, hooking it to a database connection would be the proper way to do it.

    if you need to use several small files i reccomend XML not plaintext.

    Also be sure that the script is terminating, and running on a scheduled cron.. you might have set it up to run a new insance evertime it checks for the file instead of terminating.

    to find how often you should (or the minimum time between) runs see how long it takes start to finish.

    php usaully has a small mem allocation unlike C++ because it is meant to run on a web server to do very simple/quick tasks.

Posting Permissions

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