All layouts are gotten from database or cache even when only a few of them will be shown. This behavior was detected after user login, when layout tree is rendered.
Master: LayoutsTreeImpl.java#L333-L335 and LayoutListUtil.java#L90-L91
7.1.x: LayoutsTreeImpl.java#L333-L335 and LayoutListUtil.java#L90-L91
7.0.x: LayoutsTreeImpl.java#L335-L337 and LayoutListUtil.java#L90-L91
Steps to reproduce
- Start a new tomcat bundle.
- Use jvisualvm (include with jdk) to monitor tomcat process.
- You could create a new Liferay Theme that remove breadcrumb portlet and navigation portlet. In this way, you could review that all layouts are cached for layout tree in site menu (I attached new-70-theme.war for 7.0.x an d new-71-theme.war for 7.1.x). Create and configure one page with this Liferay Theme. This step is not necessary in master.
- Go to Control Panel > Configuration > Server Administration > (tab) Script and execute attached script addTestLayouts.groovy, but first configure next variable with site groupId where 1000 pages will be created:
- Got to created page in step 3.
- Go to jvisualvm > MBeans > CacheStatistics > MULTI_VM_PORTAL_CACHE_MANAGER > com.liferay.portal.kernel.dao.orm.EntityCache.com.liferay.portal.model.impl.LayoutImpl. Review MemoryStoreObjectCount and ObjectCount.
MemoryStoreObjectCount and ObjectCount have values around default layouts showed in site menu navigation tree (By default 20).
MemoryStoreObjectCount and ObjectCount have values around 1000 (visualvm_LayoutImpl_cache_objects.png ).