java OutOfMemory 问题 - 堆转储比配置的最大堆小 800 Mb
我在 Oracle App Server 10.1.3 中部署了一个 Web 应用程序,在 oc4j 中以 1Gb 初始堆和 2Gb 最大堆启动,在 32 位 RHEL 上配置为看到 32Gb RAM。 最近,我遇到了 OutOfMemory 错误,因此我将应用程序配置为在 OutOfMem 上创建堆转储。所以我有 4-5 个堆转储,每个大小不超过 1.2 GB(因此比最大堆大小小 800 Mb)。此外,平均时间在机器上进行免费显示大约有 20Gb 的可用 RAM。
这是否意味着应用程序会尝试一次性分配 800 Mb?或者,如果有 2 个或更多线程尝试同时分配内存,它们都会失败,即使我们假设每个线程都有内存,但两者的总和却没有?难道linux机器上有一个pb,也许它不能给java提供内存?内存是否会出现碎片,也许允许 32 位机器看到 32 GB 内存的配置有一个 pb?
(我应该提到的是,应用程序最近没有改变,但是在那台机器上部署了一个新的 oc4j 和一个新的应用程序,并且消耗了 1-2g 的内存)
I have a web application deployed in Oracle App Server 10.1.3, in an oc4j started with 1Gb initial heap and 2 Gb max heap, on an RHEL on 32 bit, configured to see 32 Gb of RAM.
Lately I have experienced OutOfMemory errors, so I configured the app to create heap dumps on OutOfMem. So I have 4-5 heap dumps, each no more than 1.2 Gb in size (so 800 Mb smaller than max heap size). Also, doing a free on the machine at average hours show about 20Gb of free ram.
Does this mean that the application tries to allot 800 Mb in one go? Or if there are 2 or more threads that try to allot memory at the same time, they both fail, even if let's say there is memory for each one, but not for the sum of both? Could there be a pb with the linux machine, maybe it cannot give memory to java? Could the memory be fragmented, maybe the configuration that allows the 32 bit machine to see 32 Gb of ram has a pb?
(I should mention that the application didn't change lately, but on that machine a new oc4j and a new application was deployed laely, and that eats 1-2g of ram)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在大多数 32 位机器(包括大多数 Linux 版本)中,进程可以分配的最大内存约为 2G。现在,如果您说您的堆正在占用1.2G,那么在最坏的情况下,我会假设您的永久代正在占用剩余的 >800M。尝试设置-XX:MaxPermSize=200M并检查。
In most 32 bit machines(including most flavors of linux) the max memory your process can allocate is around 2G. Now if you say that your heap is taking 1.2G, then in worst case I would assume that your perm gen is eating the rest 800M.Try setting -XX:MaxPermSize=200M and check.
我认为你的问题是你为整个应用服务器分配了1G-2G堆大小。它本身会消耗一些内存,不确定多少。但是,如果您以最大 2G 内存启动应用程序服务器,那么您的 Web 应用程序可用内存肯定少于 2G。
I think your problem is that you allocate 1G-2G heap size for the whole App server. It consumes some memory by itself, not sure how much. But if you start the App server with max 2G memory you will have definetly less than 2G available for your webapp.