MongoDB在Grails中造成内存泄漏 [英] Memory Leak in Grails with MongoDB

查看:151
本文介绍了MongoDB在Grails中造成内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MongoDB在Grails中保存或更新多个对象时,我发现了一个奇怪的问题.目前,我正在使用Grails 2.2.3和MongoDB插件1.3.0.

I've found a strange issue when saving or updating several objects in Grails with MongoDB. Currently I'm using Grails 2.2.3 and MongoDB plugin 1.3.0.

问题似乎是当我手动调用GC时,MiUsuario的实例也从来都不是GC.在我们的主应用程序中,我们不进行批处理更新,但是在进行负载测试(使用JMeter并使用Java VisualVM监视JVM)时,此问题会导致内存填充,并且Tomcat停止响应.

The problem seems to be that the instances of MiUsuario are never GC neither when I manually call the GC. In our main application we don't make batch updates, but when doing load tests (with JMeter and monitoring JVM with Java VisualVM) this problem causes memory filling and Tomcat stops responding.

我创建了一个小的新应用程序来显示问题.

I've created a small new application to show the problem.

一个简单的域对象:

class MiUsuario {
    ObjectId id
    String nickName
}

我的控制器:

import pruebasrendimiento.Prueba

class MiUsuarioController {
    def doLogin(String privateKey, String id){
        MiUsuario user = MiUsuario.get(id)
        user.nickName = new Random().nextInt().toString()
        user.save(failOnError:true)
        render 'ok'
    }
}

我的BuildConfig(仅依赖项和插件部分):

My BuildConfig (Just the dependencies and plugins part):

    dependencies {
    }
    plugins {
    //      runtime ":hibernate:$grailsVersion" 
            runtime ":jquery:1.8.3"
            runtime ":resources:1.2"
            build ":tomcat:$grailsVersion"
    //      runtime ":database-migration:1.3.2"
    //      compile ':cache:1.0.1'
        runtime ":mongodb:1.3.0"
    }

我还尝试了Burt很久以前说过的内容( http://burtbeckwith.com /blog/?p = 73 ),但DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP.get().clear()并没有任何区别.该页面中所说的另一个选项RequestContextHolder.resetRequestAttributes()给了我一个例外.

I've also tried something that Burt said a long time ago (http://burtbeckwith.com/blog/?p=73), but DomainClassGrailsPlugin.PROPERTY_INSTANCE_MAP.get().clear() doesn't make any difference. And the other option that's said in that page, RequestContextHolder.resetRequestAttributes(), gives me an exception.

推荐答案

我遇到了类似的问题,它解决了升级到grails 2.3.1的问题.试试吧.

I had similar problem and it solves upgrading to grails 2.3.1. Try it.

这篇关于MongoDB在Grails中造成内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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