[xwiki-users] groovy and PermGen space exception
Hello, I'm having a problem with xwiki + groovy which throw PermGen exception a lot. I built a page(page A) which send ajax continuously to another page(page B) At page B, it use groovy to process the request. The problem as I checked is : It seem like each request, the engine compile and load groovy script => many Script classes, objects are created that stress out the memory. I use jconsole to check and see something like this as Loaded classes: [Loaded Script2523$_getData_closure6 from file:/groovy/script] [Loaded Script2524$_getData_closure6 from file:/groovy/script] [Loaded Script2525$_getData_closure6 from file:/groovy/script] [Loaded Script2526$_getData_closure6 from file:/groovy/script] I look like Xwiki engine use something like GroovyShell to evaluate the groovy script each time it's loaded so it create a lot of Script classes (something like that, i'm not sure) How can I fix this? or anyway to work around? Note that I have already set environment variables -Xmx512m -XX:MaxPermSize=512m -XX+CMSClassUnloadingEnabled -- View this message in context: http://xwiki.475771.n2.nabble.com/groovy-and-PermGen-space-exception-tp75908... Sent from the XWiki- Users mailing list archive at Nabble.com.
How do you use groovy script exactly ? {{groovy}} macro is using the standard JSR 223 implementation provided by Groovy, we don't have much control on what is happening. On Tue, Jun 3, 2014 at 1:31 PM, lequan.moon <[email protected]> wrote:
Hello, I'm having a problem with xwiki + groovy which throw PermGen exception a lot. I built a page(page A) which send ajax continuously to another page(page B) At page B, it use groovy to process the request. The problem as I checked is : It seem like each request, the engine compile and load groovy script => many Script classes, objects are created that stress out the memory. I use jconsole to check and see something like this as Loaded classes: [Loaded Script2523$_getData_closure6 from file:/groovy/script] [Loaded Script2524$_getData_closure6 from file:/groovy/script] [Loaded Script2525$_getData_closure6 from file:/groovy/script] [Loaded Script2526$_getData_closure6 from file:/groovy/script] I look like Xwiki engine use something like GroovyShell to evaluate the groovy script each time it's loaded so it create a lot of Script classes (something like that, i'm not sure)
How can I fix this? or anyway to work around?
Note that I have already set environment variables -Xmx512m -XX:MaxPermSize=512m -XX+CMSClassUnloadingEnabled
-- View this message in context: http://xwiki.475771.n2.nabble.com/groovy-and-PermGen-space-exception-tp75908... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Yes, i use the tag {{groovy}} for groovy script. Is there anyway else?? -- View this message in context: http://xwiki.475771.n2.nabble.com/groovy-and-PermGen-space-exception-tp75908... Sent from the XWiki- Users mailing list archive at Nabble.com.
There is also some old APIs like $xwiki.parseGroovyFromPage and also the way to insert groovy in xwiki/1.0 syntax but I doubt it's going to help you much here anyway. AFAIK yes the way groovy work is by creating a new class each time its asked to execute a script. Now in the case of groovy macro (or any other script macro) a dedicated classloader is created to hold the classes generated by the scripts but this classloader is only kept for a single request so it should be automatically wiped by the garbage collector I guess. When executing very often a script, something that should avoid the issue you have and improve performance (not building the script everytime) is to inject your groovy as a script service (see http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usin...) once and then call it with one line of Velocity for example. If it's very simple another way to workaround it is to use Velocity instead of Groovy since Velocity is not compiled. In the meantime it would be great if you could create an issue on http://jira.xwiki.org with details on how to reproduce it so that I look at it in detail with a profiler or something when I have some time and find some way to improve that. On Wed, Jun 4, 2014 at 7:24 AM, lequan.moon <[email protected]> wrote:
Yes, i use the tag {{groovy}} for groovy script. Is there anyway else??
-- View this message in context: http://xwiki.475771.n2.nabble.com/groovy-and-PermGen-space-exception-tp75908... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
OK Thanks Thomas. Temporary I tried not to use closures in script. Closure themself make the loaded classes increased. And maybe I should call System.gc() each time the request is done?? And about the issue on jira, well I must say that I not quite familiar with JIRA. Sorry about that. Maybe later when I have time to get used to JIRA -- View this message in context: http://xwiki.475771.n2.nabble.com/groovy-and-PermGen-space-exception-tp75908... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
lequan.moon -
Thomas Mortagne