Affects Version/s: 7.0.X EE, Master
Component/s: Content Display Widgets > Web Content Search widget
The JournalContentSearchLocalServiceImpl#checkContentSearches method has this line, which fetches every group in the portal instance into one List. For a small test instance this may be acceptable, but for a production size instance with potentially millions of groups, this is unacceptable as the List will take up a huge amount of memory and cause performance issues.
It gets even worse later on in the method because we create another List of every Layout associated with each of those groups. This is going to be another exceptionally large list on a production instance of Liferay portal.
In cases like these where we're going to fetch a large amount of objects into a single List, we should use ActionableDynamicQuery instead.
Steps to Reproduce
1. Start up an instance of Liferay portal.
2. Navigate to Control Panel > Configuration > System Settings > Web Content.
3. Check the box that says "Sync content search on startup" and click save.
4. Add many sites and pages to your portal (adding 1,000,000 sites each with a page is probably sufficient if you're using a 1 GB JVM).
5. Shut down the portal.
6. Start up the portal
Expected behavior: The portal starts up cleanly with no errors
Actual behavior: The portal gets an OutOfMemoryError on startup