Running out of memory

Discussion in 'PHP' started by sarahk, Feb 7, 2007.

  1. #1
    Hi,

    On a cakePHP intranet I've written I have a problem with a really large csv file.

    I've had to break it into "pages" and run multiple queries to build up the csv file slowly and that's worked for queries up to 1000 records.

    After that I run out of juice and the page fails. No errors, nothing. It's fast so it's not a timeout. I'm passing &$data to help preserve memory, but not sure what the next step should be.

    Any tuning experts around?

    thanks

    Sarah
     
    sarahk, Feb 7, 2007 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Without error message, it's a bit hard to debug. Try setting 'error_reporting' t
    o E_ALL and 'display_errors' and 'display_startup_errors' to 'On'.

    For scallability, you may also want to store the CSV output in a temporary file on the server while you're getting the data, instead of storing it in a variable. Then in the end just send this temporary file away. This way, you'll be using disk space with minimal use of memory.
     
    phper, Feb 7, 2007 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,828
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #3
    Thanks

    I tried all sorts of ingenious steps. I queried the data in batches and wrote the csv file in even smaller batches.

    I just got it sorted and that was by upping the memory allocation via the .htaccess file.

    thanks for your response.
     
    sarahk, Feb 8, 2007 IP