This article is a legacy article. It applies to previous versions of the Liferay product. While the article is no longer maintained, the information may still be applicable.
This article addresses memory issues caused by JRuby, a Java implementation of the Ruby programming language. Liferay Portal currently uses JRuby to run Sass for the purpose of processing CSS.
The following list outlines a number of steps that may be taken to reduce the memory impact of JRuby in your Liferay environment:
There is currently an issue (LPS-34419) which addresses the
perm. gen. space memory leak caused by JRuby. To get this fix, simply open a ticket and our Subscription Services team will gladly provide it.
Hooks with CSS
When CSS is used in hooks, JRuby will likely be triggered to start filling with memory. Therefore, to limit memory consumption, limit the overriding of core CSS files with hooks as much as possible and instead apply CSS through the theme.
To reduce the possibility of memory issues caused by
context.xml, remove the attribute
antiResourceLocking="true" from all of the
context.xml files in your already deployed portlets.
If you haven't modified the context.xml files manually, you can simply delete the whole context.xml file. The context.xml files can be found in
There is an issue (LPS-29750) in some versions of Liferay Portal that will cause the overriding of each portlet's context.xml file upon deployment. Therefore, it is important to check the contents of each portlet's context.xml file as the contents may have changed and may be causing memory issues.
Build the .sass-cache of Your Portlets
When creating a portlet, make sure to run the ‘build-css’ ant task. This takes care of building the .sass-cache files, so the portal won’t have to do it runtime. Once you built it, redeploy the portlet to all nodes.
Even if the portlet itself does not use SASS, it is still recommended to run the build-css task. At the very least, manually create an empty
.sass-cache folder in the portlet’s css folder.
Check to see if the user running Liferay Portal has permissions to create files on the filesystem
Sometimes issues may arise because the user running Liferay does not have the required privileges to create either the
.sass-cache folder, or the files within them. Please make sure that this user has write permission to the folders.
Run the Attached Groovy Script
When the portal reaches out for the compiled CSS files, it first checks to see if the timestamps are the same for the CSS file and the compiled CSS. If the timestamps aren’t the same, then the portal recompiles the CSS on the fly. This can also cause memory issues, especially if there are a lot of files that have mismatching timestamps.
Running the attached groovy script resolves some of these issues by updating the timestamps so that they match. In addition, it also prints out the processed files and all of the used properties which might be useful for the Support Team should you be in touch with them. The script creates an output file at the following location:
Please note, that running this script has one side effect: If you have included custom CSS in any hooks, these will be lost as soon as the cache is invalidated.
If you are in a clustered environment, make sure to run the script for all nodes.