为什么我的Tomcat JRuby应用程序中永远不会释放内存?

Lie*_*oen 5 java tomcat ruby-on-rails jruby jrubyonrails

我有一个JRuby on Rails应用程序,它运行在Tomcat(Warble)中.它使用Java桥连接到Progress(OpenEdge)应用程序服务器......当我监视内存时,它只会继续运行.

  • Tomcat 7.0
  • JRuby 1.6.7.2(Ruby-1.9.2-p312)
  • JVM 1.7.0.25
  • Rails 3.2.7
  • jruby-rack 1.1.7
  • 鸣鸟1.3.6

在这里找到问题的最佳方法是什么?我想它可能是未清理的JRuby对象,或者是Java桥或垃圾收集器中没有完成其工作的东西......

即使我让这个过程运行了半个小时,内存也不会下降......

  • 有没有办法知道哪些物体还活着?
  • 是否有易于使用的免费工具,通过这些工具,我可以获得有关谁使用所有内存的更多信息?

By the way, I already have configured the Tomcat server to use more memory, but that's just delaying a heap space error...

EDIT: What I'm actually seeing is that Tomcat just uses all the memory that it can maximum use (Maximum memory pool). And it never releases it. Maybe it's just normal behavior... I've now set maximum to 256MB for example and in the Task Manager, the memory just stays around 256MB.

EDIT:

When creating a heap dump and letting eclipse analyze it with the Eclipse Memory Analyzer this is the report I'm getting. I think it's normal since the tool probably doesn't expect the whole JRuby story...

Problem Suspect 1

6.458 instances of "org.jruby.RubyClass", loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988" occupy 56.969.616 (31,78%) bytes.

Keywords org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988 org.jruby.RubyClass

Problem Suspect 2

10.597 instances of "org.jruby.internal.runtime.methods.DefaultMethod", loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988" occupy 22.182.112 (12,37%) bytes.

Keywords org.jruby.internal.runtime.methods.DefaultMethod org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988

Problem Suspect 3

3.144 instances of "org.jruby.RubyModule", loaded by "org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988" occupy 21.226.816 (11,84%) bytes.

Keywords org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988 org.jruby.RubyModule

Problem Suspect 4

8.888"org.jruby.MetaClass"实例,由"org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988"加载,占用18.563.784(10,35%)个字节.

关键字org.jruby.MetaClass org.apache.catalina.loader.WebappClassLoader @ 0x700ec6988

Ter*_*for 1

这闻起来很像内存泄漏。景色不太美。

如果代码不多,请首先检查是否正在关闭连接、流以及所有具有 method 的对象close。如果这是最近出现的问题,请查看上次修改的代码。

我会尝试的另一件事是使用某种工具进行代码检查。

也许编写一些测试来加速泄漏(例如生成请求),然后您可以尝试从应用程序中排除代码,直到找到导致泄漏的区域。

我不建议您检查内存中的对象,因为这是一个缓慢而痛苦的过程。