No Code Attached Yet
avatar anilalci
anilalci
12 Mar 2023

Steps to reproduce the issue

Call Route::_ method one million times for different url

Expected result

low memory usage

Actual result

high memory usage

System information (as much as possible)

memory_limit = 1G

Additional comments

One of them can be a solution;

  • cache on/off configurable
  • clean cache method
  • object limit for cache
avatar anilalci anilalci - open - 12 Mar 2023
avatar joomla-cms-bot joomla-cms-bot - change - 12 Mar 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 12 Mar 2023
avatar joomdonation
joomdonation - comment - 13 Mar 2023

Our routing system stores the processed URLs into Router::$cache so that it does not have to handle building process more than one time for the same URL. Please note that this is in memory cache, data in Router::$cache are the URLs for each page load. In real life usages, there won't be that large number of URLs per page, so I think the current implementation is fine.

Since this is in memory cache for each page load, I think the solutions you suggested are not applicable, too.

avatar anilalci
anilalci - comment - 13 Mar 2023

Yes, it is fine for general real-life usage.
But in my case, there are more than three million pages on my website.
I have a CLI app in Joomla to build a sitemap.
Router::$cache is a protected variable, so I can't access it directly.
I have to remove or disable that cache in my app.
How can I override class Router or class SiteRouter?

avatar Hackwar Hackwar - change - 13 Mar 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-03-13 11:24:36
Closed_By Hackwar
avatar Hackwar Hackwar - close - 13 Mar 2023
avatar Hackwar
Hackwar - comment - 13 Mar 2023

You can create a system plugin which loads your version of the router class either during construction of the plugin object or on the event onAfterInitialise. We will not remove the cache for the router in the CMS by default.

avatar joomdonation
joomdonation - comment - 13 Mar 2023

@Hackwar Could you please provide an example code which allows loads your version of the router class ? That would help users who has similar requirement.

avatar Hackwar
Hackwar - comment - 13 Mar 2023
<?php
use Joomla\CMS\Plugin\CMSPlugin;

class plgSystemMyownrouter extends CMSPlugin
{
	public function onAfterInitialise()
	{
		require_once __DIR__ . '/router.php';
	}
}

And in the router.php you have your copy of the router class.

avatar joomdonation
joomdonation - comment - 13 Mar 2023

Thanks !

Add a Comment

Login with GitHub to post a comment