[PENDING REVIEW] Memory Exhausted when adding new Menu Item

thrice
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri May 05, 2006 10:57 am

[PENDING REVIEW] Memory Exhausted when adding new Menu Item

Postby thrice » Fri May 05, 2006 11:17 am

Hi everybody,

I'm new to the Joomla forums and I hope that I'm posting enough info and I'm right in here.
So, here's my "Bug":

When trying to add a new Menu Item with the Menu Manager, I get this error in Joomla 1.0.8):

Code: Select all

Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 4057 bytes) in /path/to/my/website/includes/joomla.php on line 2964

The error occurs when I select a Menu Type (it does not matter which type I'm selecting) and press the "Next" Button.
I've tried this on 3 different websites, hosted by 3 different companies.
On an 1&1 Virtual Server with a memory_limit of 32MB it works. On a webspace from http://www.all-inkl.com with memory_limit of 40 MB it does not work. And on a http://www.kontent.de webspace with 10 MB it doesn't work also.
Please don't tell me to change the memory_limit in the php.ini, because I can't do that. What makes me think is that it works with 32MB memory_limit, but it does not with 40MB. What could be the reason?
Is there an error in this function?

Code: Select all

function mosTreeRecurse( $id, $indent, $list, &$children, $maxlevel=100, $level=0, $type=1 ) {
   if (@$children[$id] && $level <= $maxlevel) {
      foreach ($children[$id] as $v) {
         $id = $v->id;

         if ( $type ) {
            $pre    = '<sup>L</sup> ';
            $spacer = '.      ';
         } else {
            $pre    = '- ';
            $spacer = '  ';
         }

         if ( $v->parent == 0 ) {
            $txt    = $v->name;
         } else {
            $txt    = $pre . $v->name;
         }
         $pt = $v->parent;
         $list[$id] = $v;
         $list[$id]->treename = "$indent$txt";
         $list[$id]->children = count( @$children[$id] );
         $list = mosTreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type );
      }
   }
   return $list;
}


I'm not a PHP programmer, but it seems to me that there's something wrong with the function.
Has anyone an idea what to do?

Regards,

Chris
Last edited by stingrey on Sun Jun 04, 2006 4:19 pm, edited 1 time in total.

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: 1.0.8 Memory Exhausted when adding new Menu Item

Postby stingrey » Thu May 11, 2006 10:44 pm

How many menu items are in the menus where you see this occurring compared with where it is working properly?
Do you see this error in a blank/empty menu?

The function is recursive, so it is possible that it is looping far too many times and exhausting your systems available memory
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

User avatar
timail
Joomla! Intern
Joomla! Intern
Posts: 82
Joined: Sun Aug 21, 2005 8:54 pm
Location: Potsdam / Germany
Contact:

Re: 1.0.8 Memory Exhausted when adding new Menu Item

Postby timail » Wed May 17, 2006 7:07 am

same problem with me.

i think it does not depend on the number of menu-items for real...

we knew this problem from some Joomla 1.0.8-Installations on the servers of our customers.

changing the memory_limit in the php.ini solves it, but does this script need so much memory if it is correct???

thanks and kind regards tim.

jorgejordao
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Oct 20, 2006 11:36 am

Re: [PENDING REVIEW] Memory Exhausted when adding new Menu Item

Postby jorgejordao » Fri Oct 20, 2006 11:38 am

I've got the same error on joomla 1.0.11 Stable.

I will try to change the php.ini

User avatar
corrado444
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Thu Jul 06, 2006 8:30 am
Location: Sacramento
Contact:

Re: [PENDING REVIEW] Memory Exhausted when adding new Menu Item

Postby corrado444 » Sat Oct 28, 2006 2:28 am

I am getting the same error by using CB and clicking on "profile"
I managed to fix it by inserting this code in the configuration.php

Code: Select all

ini_set('memory_limit', '12M');


Hoever, the day after the error popped out again this time in the confirmation email link for new uers.
I checked configuration.php and my code was gone.
I added it again and the problem disappeared once more.

What is the cause of the error and why di the config file deleted the code?
Watch the 10 Minute Joomla! Tips Video Podcast
Itunes: itpc://10minutejoomlatips.blip.tv/rss/itunes
Feedburner http://feeds.feedburner.com/10MinutesJoomlaTips

harveyn
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Thu Sep 15, 2005 4:22 pm

Re: [PENDING REVIEW] Memory Exhausted when adding new Menu Item

Postby harveyn » Fri Nov 03, 2006 5:14 pm

This problem originates in the xml_domit_lite_parser.php file when executing the function parse() (approx. line 1012) in function parseXML() a lot of xml stuff takes place. Using the php function memory_get_usage() (all over the place) I tracked it down to line (approx.) 1767:

Code: Select all

$success = xml_parse($parser, $xmlText);

this adds 200kb to the memory being used generating the page for every menu item so if you have 25 menu items this totals up to 5MB! this usage is never freed up and so when generating the viewMenuItems page it quickly passes the 8MB mark.

I'm not hot enough on what the parser is doing to work out why it doesn't free up the memory on each iteration but this is definately something which needs sorting. This process is only getting the tooltip stuff on the type column - I think it would be easier if when creating the menu items it stored the neccessary info as in the table instead of having to run the xml parser stuff for every menu item.

For the time being my solution to get past the problem is to comment out the loop that reads the xml files and to just output the basic type on the main menu items page:

administrator/components/com_menus/admin.menus.php :: function viewMenuItems() -
between (approx.) lines 245 and 252 comment out the block like so

Code: Select all

//   $i = 0;
//   foreach ( $list as $row ) {
//      // pulls name and description from menu type xml
//      $row = ReadMenuXML( $row->type, $row->com_name );
//      $list[$i]->type    = $row[0];
//      if (!isset($list[$i]->descrip)) $list[$i]->descrip = $row[1];
//      $i++;
//   }


administrator/components/com_menus/admin.menus.html.php :: function showMenusection() -
replace line (approx.) 152

Code: Select all

echo mosToolTip( $row->descrip, '', 280, 'tooltip.png', $row->type, $row->edit );

with simply

Code: Select all

echo $row->type;


As I said if anyone knows the parser better they can probaly crack this either that or the relevant info should be stored in the table when the menu item is first created - this is probably the better option actually as it cuts out a seemingly huge amount of what is unneccessary processing.

Phew!



Old unwanted telephone directorys make ideal personal address books - simply cross out the names and addresses of all the people you don't know.

wips
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Sep 27, 2005 5:21 am
Location: east onia

Re: [PENDING REVIEW] Memory Exhausted when adding new Menu Item

Postby wips » Sun Nov 05, 2006 8:22 am

I had long time problems with memory exhaust and I tracked the problem to the same line in the xml_domit_lite_parser.php,

Code: Select all

$success = xml_parse($parser, $xmlText);

however I could not see any reason for it in the code. This was a problem not only with adding menu items, but also with content, etc. Increasing the memory limit for php did not help me at all.
Finally I came into a conclusion that the problem resides in server configuration, that is php 5.0.5. My service provider allows to choose different php versions, 4.4.4 and 5.1.6 work without problems.
information is the most important building material


Return to “Known Issues - Archive”

Who is online

Users browsing this forum: No registered users and 1 guest