regular expression memory problems

Discussion in 'PHP' started by jamespv85, Jul 23, 2009.

  1. #1
    anyone got problems with PHP running into `out of memory` error when using a certain regular expression?

    i got this pattern,

    BEGINS_WITH(\n|.)*ENDS_WITH

    which is supposed to match a string that BEGINS_WTH and stops when it sees string ENDS_WITH, but this just goes over multiple lines.

    manually it would work. but in a loop it would run for like a few and then just stop saying PHP is out of memory.
     
    jamespv85, Jul 23, 2009 IP
  2. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have the exact error message when it runs out of memory? (some hosts can start you off small with 8MB, but you can bump that to 16 or 32 using iniset in most cases, which is often times required to run wordpress or GalleryV2 and so forth, depending on your specific setup)
     
    kblessinggr, Jul 24, 2009 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Can you post your code. Most likely you need to clear out some string or array at the beginning of each loop to clear up some memory.
     
    jestep, Jul 24, 2009 IP
  4. jamespv85

    jamespv85 Peon

    Messages:
    238
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Adjusting the memory is not a very good solution me thinks. But thanks for the suggestions. I'll try to put the code, I'm on the road right now.

    It's basically simple. I got a list of links that it goes through, probably a thousand. Then it just goes through these pages getting a few strings like name, address, etc. The pages aren't big. 20-30Kb per page. Doing this manually is gonna take me ages! LOL!

    I've done this several times, but with a different regular expression. That one above is the one that gets me the OOM error.
     
    jamespv85, Jul 25, 2009 IP