Jump to content

Allowed memory size error on menu module


Recommended Posts

Hi all, I have a problem with a menu module.

 

I have this complex structure:

 

d757af1ac6ab73e33da0d10adf0a9ea2.png

 

and so on.

 

The main problem is the frontend rendering: it prints me

 

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 9263430 bytes) in /home/wwwsite/isaytest.com/htdocs/stereomuch/modules/wdblocktopmenu/wdblocktopmenu.php on line 573

 

Now, is it possible that 512mb isn't enough to render a third-level menù? The function

getCategory()

of this module is almost the same as the

getCategory()

in the blocktopmenu module.

 

This is the code:

 

private function getCategory($id_category, $id_lang = false, $id_shop = false)
{
	$id_lang = $id_lang ? (int) $id_lang : (int) Context::getContext()->language->id;
	$category = new Category((int) $id_category, (int) $id_lang);
	if ($category->level_depth > 1)
		$category_link = $category->getLink();
	else
		$category_link = $this->context->link->getPageLink('index');
	if (is_null($category->id))
		return;
	$children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
	$selected = ($this->page_name == 'category' && ((int) Tools::getValue('id_category') == $id_category)) ? ' class="sfHoverForce"' : '';
	$is_intersected = array_intersect($category->getGroups(), $this->user_groups);
	// filter the categories that the user is allowed to see and browse
	if (!empty($is_intersected)) {
		if (count($children)) {
			$this->_menu .= '<li ' . $selected . ' class="parent">';
		} else {
			$this->_menu .= '<li ' . $selected . '>';
		}
		$this->_menu .= '<a href="' . $category_link . '">' . $category->name . '</a>';
		$parent = 'parent';
		if (count($children)) {
			$this->_menu .= '<ul>';
			foreach ($children as $child)
				$this->getCategory((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop']);
			$this->_menu .= '</ul>';
		}
		$this->_menu .= '</li>';
	}
}

Edited by Isb (see edit history)
Link to comment
Share on other sites

hi

 

try to increase the memory limit in php.ini the default may be 32mb try to increase it to 64mb are more.surely you will get it. the file php.ini is in your domain.

 

Hi Karthik, like i said the actual memory limit is 512mb, not 64 or 32mb. I find very absurd that a third level menù require more than 512mb of memory to be rendered.

Link to comment
Share on other sites

have you tried for 1024mb? how many categories you have?

 

I can't go further 512 MB ( Host limit ). Hovewer look at the first post, where there is an image of all categories :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...