如何提高Jboss的内存使用量?
我有一个在 jboss-5.0.0.GA 上运行的 Java EE 应用程序。该应用程序使用 BIRT 报告工具生成多个报告。
该服务器有 4 个 2.4 Ghz 核心和 8 Gb 内存。
启动脚本使用以下选项:
-Xms2g -Xmx2g -XX:MaxPermSize=512m
应用程序已通过此配置达到了一定的稳定性,前段时间由于内存完全满,我发生了很多崩溃。
现在,应用程序没有崩溃,但内存始终被充分使用。 top 命令示例:
Mem: 7927100k total, 7874824k used, 52276k free
java 进程显示使用 2.6g,这是该服务器上运行的唯一应用程序。
我该如何确保有足够的可用内存?
我可以做什么来尝试查找内存泄漏?
还有其他建议吗?
TIA
基于 mezzie 的回答:
如果您使用的是 Linux,那么 内核对内存的作用是 与 Windows 的工作方式不同。在 linux,它会尝试用完所有的 记忆。当它使用所有东西后,它 然后将回收内存 进一步使用。这不是记忆 泄露。我们的系统上也有 jboss tomcat Linux 服务器,我们做了研究 不久前这个问题。
我找到了更多关于此的信息,
http://lwn.net/Articles/329458/
好吧,一半内存已缓存:
total used free shared buffers cached
Mem: 7741 7690 50 0 143 4469
I have a Java EE application running on jboss-5.0.0.GA. The application uses BIRT report tool to generate several reports.
The server has 4 cores of 2.4 Ghz and 8 Gb of ram.
The startup script is using the next options:
-Xms2g -Xmx2g -XX:MaxPermSize=512m
The application has reached some stability with this configuration, some time ago I had a lot of crashes because of the memory was totally full.
Rigth now, the application is not crashing, but memory is always fully used.
Example of top command:
Mem: 7927100k total, 7874824k used, 52276k free
The java process shows a use of 2.6g, and this is the only application running on this server.
What can I do to ensure an amount of free memory?
What can I do to try to find a memory leak?
Any other suggestion?
TIA
Based in answer by mezzie:
If you are using linux, what the
kernel does with the memory is
different with how windows work. In
linux, it will try to use up all the
memory. After it uses everything, it
will then recycle the memory for
further use. This is not a memory
leak. We also have jboss tomcat on our
linux server and we did research on
this issue a while back.
I found more information about this,
http://lwn.net/Articles/329458/
And well, half memory is cached:
total used free shared buffers cached
Mem: 7741 7690 50 0 143 4469
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 Linux,内核对内存的处理方式与 Windows 的工作方式不同。在linux中,它会尝试用完所有内存。当它使用完所有内容后,它将回收内存以供进一步使用。这不是内存泄漏。我们的 Linux 服务器上也有 jboss tomcat,不久前我们对这个问题进行了研究。
If you are using linux, what the kernel does with the memory is different with how windows work. In linux, it will try to use up all the memory. After it uses everything, it will then recycle the memory for further use. This is not a memory leak. We also have jboss tomcat on our linux server and we did research on this issue a while back.
我敢打赌这些是操作系统内存值,而不是 Java 内存值。 Java 使用 -Xmx 之前的所有内存,然后开始垃圾收集,这大大简化了。使用jconsole查看真实的Java内存使用情况是多少。
I bet those are operating system mem values, not Java mem values. Java uses all the memory up to -Xmx and then starts to garbage collect, to vastly oversimplify. Use jconsole to see what the real Java memory usage is.
为了简单起见,JVM 的最大内存量 us 等于 MaxPermGen(在 JVM 运行时永久使用。它包含类定义,因此它不应该随着服务器的负载而增长)+ Xmx(最大内存大小)对象堆,其中包含当前在 JVM 中运行的对象的所有实例)+ Xss(线程堆栈空间,取决于 JVM 中运行的线程数量,大多数情况下对于服务器来说是有限的)+ 直接内存空间(由 -XX:MaxDirectMemorySize=xxxx 设置)
所以做一下数学计算。如果您想确保还有可用内存,则必须限制 MaxPermGen、Xmx 和服务器上允许的线程数。
风险是,如果服务器上的负载增加,您可能会遇到 OutOfMemoryError...
To make it simple, the JVM's max amount of memory us is equal to MaxPermGen (permanently used as your JVM is running. It contains the class definitions, so it should not grow with the load of your server) + Xmx (max size of the object heap, which contains all instances of the objects currently running in the JVM) + Xss (Thread stacks space, depending on the number of threads running in you JVM, which can most of the time be limited for a server) + Direct Memory Space (set by -XX:MaxDirectMemorySize=xxxx)
So do the math.If you want to be sure you have free memory left, you will have to limit the MaxPermGen, the Xmx and the number of threads allowed on your server.
Risk is, if the load on your server grows, you can get an OutOfMemoryError...