• Resolved swichers

    (@swichers)


    I have a large number of posts that I am importing from b2evolution. I originally had a script that worked fine by importing directly to the database (Based on the old b2evo->wp2.3 script). I thought I would be “smarter” and use the built-in WordPress functions for inserting categories, posts, and comments.

    Unfortunately this seems to be causing significant problems. WordPress has many small memory leaks that add up very quickly when you are doing large imports of data (e.g. 1800+ categories and 20,000+ posts).

    I have tracked some of these leaks down to the liberal use of create_function where it is unnecessary (e.g. many of the preg_replace_callback calls). Replacing create_function with an actual function (or keeping track of existing create_function results when necessary) has helped somewhat.

    There still seem to be some behind the scenes things that are causing small leaks that add up over time. I believe the next issue I see is the object cache is keeping track of every category/post/comment. Is there a way that I can clear or disable this cache on a script-by-script basis? (I don’t mean to imply that the object cache is a leak, just that the functionality is undesirable while importing)

    Long story short:

    I have a lot of data I am importing that causes little memory leaks in WP to become big problems. I fixed some of the leaks. Can I disable/clear the object cache?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Can I disable/clear the object cache?

    If you disable the object cache, WordPress will crawl.

    However, if you need to clear it from time to time in your script, look at wp_cache_flush() function.

    Best regards,
    Vladimir

    Thread Starter swichers

    (@swichers)

    Hey, hey. I don’t know how I missed that function on the cache page. That seems to have made enough of a difference to let me import all the posts (as long as I go blog by blog). Next up is comments. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress and memory leaks’ is closed to new replies.