• Resolved komodosp

    (@komodosp)


    I am trying to run a get_posts in order to get all the posts, as I want to process every one of them.

    However I’m having a problem with memory – according to memory_get_usage(), this one call increases the memory usage of wordpress by 11MB (retrieving 364 posts). This isn’t too bad, as I could just do it a few posts at a time, but the memory doesn’t free up afterwards…

    I am unset()ing the return value array but this makes little difference, reducing it by only about 1.5MB. So whether I do one post at a time or all 364 of them in one get_posts query I still run out of memory. I’ve tried calling wp_reset_query() and it makes no difference at all.

    Is there a way around this?

Viewing 1 replies (of 1 total)
  • Thread Starter komodosp

    (@komodosp)

    As usual I spend the whole day trying to figure it out and soon after I post the message I finally do.

    Turns out the problem was that calling get_posts also fills the wp_object_cache which was using all the memory. A simple wp_cache_flush() was the solution…

Viewing 1 replies (of 1 total)

The topic ‘get_posts memory usage’ is closed to new replies.