﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
21672,Custom menu memory problem,pavelevap,,"I found some strange memory problem related to updating custom menu. One website is using about 22 MB from 128 available (memory_limit). But when trying to update custom menu, there is error related to unsufficient memory.

This custom menu has about 100 items, I also tried to export it to my PC and testing memory uasge. There are some strange results...

In file wp-admin/nav-menus.php there is following line:

{{{
$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
}}}

When I set memory checks before and after this line, then there are following results on my testing environment, for example:

{{{
Before: 25.28 MB
After: 25.29 MB
}}}

I added also some checks directly into wp_update_nav_menu_item() function and there are some small peaks (about 1 MB). But in the end (after this function) everything is somehow reset and memory usage is as low as in the beginning.

But when I test it with affected hosting, there are following results:

{{{
Before: 26.59 MB
After: 27.77 MB
}}}

So everytime wp_update_nav_menu_item() is running, 1 MB more is needed on this server and there is no reset. And because it is foreach cycle and menu has more than 100 items, then more then 128 MB is needed.

Same conditions, but one server needs more than 128 MB memory_limit and my local environment works well with 32 MB. There is no other problem with this hosting, everything works, no special server settings. Any ideas?",defect (bug),new,normal,Awaiting Review,Menus,3.4.1,normal,,,pavelevap@… xoodrew@…
