Support » Requests and Feedback » Memory usage, query, globals optimization

  • 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 :

    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

  • The topic ‘Memory usage, query, globals optimization’ is closed to new replies.