Foros de discusión

Excessive memory usage with Liferay stripFilter

donino donino, modificado hace 11 años.

Excessive memory usage with Liferay stripFilter

Junior Member Mensajes: 81 Fecha de incorporación: 2/07/11 Mensajes recientes
Hi,

I use Liferay 6.1.1.GA2 with tomcat 7

I encounter memory issues in my context, the main is due to JRuby and is described in a separate thread. Here is another one with the Liferay Class StripFilter. A heap dump processed in a memory profiler shows it retains more than 60 Mb memory, and keeps growing.



I disabled this StripFilter in portal-ext.properties and it fixed this issue. Please could anyone tell me if this memory usage seems normal for the StripFilter, or if i should log a JIRA issue?

Thanks
thumbnail
Manish Kumar Jaiswal, modificado hace 11 años.

RE: Excessive memory usage with Liferay stripFilter

Regular Member Mensajes: 153 Fecha de incorporación: 25/11/08 Mensajes recientes
I too faced some issues with stripfilter . It was causing constant rise of memory usage . I think there is something wrong in stripfilter.

Regards
Manish
donino donino, modificado hace 11 años.

RE: Excessive memory usage with Liferay stripFilter

Junior Member Mensajes: 81 Fecha de incorporación: 2/07/11 Mensajes recientes
Thank you for your feedback with this issue Manish
regards
thumbnail
Sampsa Sohlman, modificado hace 11 años.

RE: Excessive memory usage with Liferay stripFilter

Regular Member Mensajes: 230 Fecha de incorporación: 27/09/07 Mensajes recientes
Hi donino,

donino donino:
Please could anyone tell me if this memory usage seems normal for the StripFilter, or if i should log a JIRA issue?


Just by quickly looking the code of StripFilter it contains cache and that probably explain the memory usage.

That cache is controlled by portal-ext.properties.

    #
    # The strip filter will attempt to cache inline minified CSS and JavaScript
    # content. Set this property configure the maximum pieces of cached content.
    # Set this property to 0 to disable caching of inline minified content.
    #
    minifier.inline.content.cache.size=10000


So if you adjust that number do you see changes on your tests?
donino donino, modificado hace 11 años.

RE: Excessive memory usage with Liferay stripFilter

Junior Member Mensajes: 81 Fecha de incorporación: 2/07/11 Mensajes recientes
Thank you for your response Sampsa.

I did not realize the StripFilter was caching inline javascript fragments. By looking at the code i now understand why some projects encounter this issue. I think it may be a "dangerous" feature because inline javascript is often dynamic, for example developpers and some frameworks may want to send resource & action URL to the client-side code. Also for WSRP compatility, some projects have to include dynamic javascript content directly in the html markup.

In my context i send a pretty large JSON object (7-8k) as a javascript parameter. This object is different for each portlet session, and may change within a session depending on user actions. I see in the StripFilter code that a javascript fragment is used both as key and as content for each cache entry: that means i potentially loose 15kb memory on a page refresh, at least 50k per user session. It probably explains everything! To fix it i will wrap this JSON object in an ajax call. Pending this, setting the cache parameter to 0 should do the job:

minifier.inline.content.cache.size=0
(in my opinion it could be the default value)

Thanks!
thumbnail
Manish Kumar Jaiswal, modificado hace 11 años.

RE: Excessive memory usage with Liferay stripFilter

Regular Member Mensajes: 153 Fecha de incorporación: 25/11/08 Mensajes recientes
yes you are correct also we can also skip some javascript or CSS contents by referring in these properties


minifier.inline.content.cache.skip.css=
minifier.inline.content.cache.skip.javascript=getSessionId,encryptedUserId

Regards
Manish