更改Grails的Groovy版本 [英] Change Grails' Groovy version

查看:154
本文介绍了更改Grails的Groovy版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Grails 1.3.7使用的groovy版本更改为groovy 1.7.9?



我在Grails 1.3.7应用程序中遇到了这个问题,其中Quartz进程每分钟都会实例化500个新对象,如下所示:

  class Foo {
Bar bar
Date d = new Date()
int v
}

def f = new Foo(bar:b,v:value)

什么我注意到,每次运行都会花费更长的时间。起初,这需要几个纳秒,但是当应用程序崩溃时,PermGen内存不足错误,这个过程有时需要超过10秒...来实例化一个对象!



我采用了一些堆转储,并发现CallSiteClassLoader正在从以前安装的对象中获取大量内存。在阅读这篇线程我决定直接更换我的WAR中的groovy jar。现在应用程序正常运行,并且在几次堆转储之后,似乎没有内存泄漏。

但是我生成的每个WAR,都会继续使用groovy 1.7.7,我必须手动修改它。



谢谢!

解决方案

您可以取消注释 mavenCentral()(在 repositories 下)并添加依赖关系

  compile'org.codehaus.groovy:groovy-all:1.7.9'

(在依赖关系下)在BuildConfig.groovy中。



不知道这是否被推荐。至少这个版本会用groovy 1.7.9来包装你的应用程序,就像你现在手动做的那样。
grails run-app 仍然会使用1.7.7我猜,但这可能不是问题,因为在开发过程中遇到permgen问题之前可能会重新启动。 / p>

我选择继续使用Grails 1.3.6,直到发布Groovy 1.7.9或更高版本的Grails版本。


How can I change the groovy version used by Grails 1.3.7 to groovy 1.7.9?

I'm having this problem in a Grails 1.3.7 application in which every minute a Quartz process instantiates some 500 new objects like this:

class Foo{
 Bar bar
 Date d = new Date()
 int v
}

def f = new Foo(bar:b, v:value)

What I'm observing is that on each run, this is taking longer. At first, it takes a few nanoseconds, but by the time the application crashes with a PermGen out of memory error, this process takes, sometimes, more than 10 seconds... to instantiate an object!

I've take a few Heap Dumps and found that a CallSiteClassLoader was taking an enormous amount memory from previously instated objects. After reading this thread I decided to directly change the groovy jar's in my WAR. Now the application is running smoothly as it should, and again, after a few Heap Dumps, there seem to be no memory leaks.

But each WAR I generate, keeps coming with groovy 1.7.7 and I have to manually change it.

Thanks!

解决方案

You could uncomment mavenCentral() (under repositories) and add dependency

compile 'org.codehaus.groovy:groovy-all:1.7.9'

(under dependencies) in BuildConfig.groovy.

Don't know if this is recommended. At least the build will package your application with groovy 1.7.9 like you do manually now. grails run-app will still use 1.7.7 I guess, but that's probably not an issue, as you might restart before running into permgen problems during development.

I chose to stay on Grails 1.3.6 until a Grails version with Groovy 1.7.9 or higher is released.

这篇关于更改Grails的Groovy版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆