0

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?

2
  • did u solve the problem ? Commented Nov 29, 2018 at 16:03
  • maybe try define( 'SAVEQUERIES', false );
    – Poe
    Commented Nov 29, 2018 at 22:48

1 Answer 1

0

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

2
  • 2
    That doesn’t really answer anything. Why are so many queries stored? How did you resolve that?
    – fuxia
    Commented Feb 28, 2013 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
    Commented Feb 28, 2013 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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