Title: get_posts memory usage
Last modified: August 20, 2016

---

# get_posts memory usage

 *  Resolved [komodosp](https://wordpress.org/support/users/komodosp/)
 * (@komodosp)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/get_posts-memory-usage/)
 * 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](https://wordpress.org/support/users/komodosp/)
 * (@komodosp)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/get_posts-memory-usage/#post-2293305)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [komodosp](https://wordpress.org/support/users/komodosp/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/get_posts-memory-usage/#post-2293305)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
