WordPress.org

Ready to get started?Download WordPress

Forums

Memory usage, query, globals optimization (1 post)

  1. Calvaria
    Member
    Posted 3 years ago #

    Hi,

    I recently decided to use wordpress for my blog.

    Today, after i was adding some pages and when i wanted to add some links to menu, i've got the infamous error :

    Allowed memory size of xxx bytes exhausted

    I found it incredible especially when you know that i've only 2 articles, around 10 pages (each page contains around 150k characters) and 3 plugins activated (advanced excerpt, SI CAPTCHA, wp-paginate).

    I googled the error and the only answer i found was to extend the memory limit. But it'll only get around the problem, not solve it.

    So i decided to find why WP was using so much memory.
    I did a :
    print_r($GLOBALS);

    and i was very surprised to see every articles and pages contents there, while they weren't displayed in the page.

    The problem seems to be the WP_Query's get_posts function. It's used almost everywhere and even if the contents aren't displayed, they are stocked in $GLOBALS variable.

    It seems to be even more serious in the edit menu page. You can try by yourself, add to the end of nav-menus.php the following code :

    echo memory_get_usage();

    Go to the page with your browser, then add a very long article (like 100k characters) et the memory usage will increase drastically.

    I think that we need to find a way to change the class or the function in order to get the content only when it's useful.

    I'm sure that it'll, at least, decrease this kind of problem.

    So, what do you think?

    PS : sorry, i'm not very used to write in english

Topic Closed

This topic has been closed to new replies.

About this Topic