Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using wp_insert_post in a loop to insert 500 posts in a new WP install. It works quickly, and memory usage is from 25M to 28M. The next run of a second batch of 500 posts, takes the memory from 25M to 178M. So the memory usage seems to be based on how many posts are already in the table. A third run of 500 posts exhausts the available memory. What is being stored to increase the memory that I can cleanup?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Did some profiling, it was the 5k+ queries being stored in the $wpdb->queries array.

share|improve this answer
1  
That doesn’t really answer anything. Why are so many queries stored? How did you resolve that? –  toscho Feb 28 '13 at 22:17
    
Unless SAVEQUERIES is defined as false, WP will save every query it makes in $wpdb->queries. I mentioned I was running 500+ inserts in a loop, that adds up to a lot of queries. Those queries take up space in memory as the loop progresses. –  Poe Feb 28 '13 at 22:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.