64 位 Linux 上的意外 JVM 行为

发布于 2024-09-11 22:35:53 字数 1054 浏览 2 评论 0原文

我尝试比较我的 Java Web 应用程序在 32 位 Windows 和 64 位 Linux 上的行为。

当我通过 jconsole 查看内存使用情况时,我发现内存使用情况的图表非常不同。 在 Windows 上,应用程序永远不会触及 512m。 然而,当我在带有 64 位 VM 的 linux 64 位上运行时,内存不断增加并很快达到约 1000m 的峰值,并且我还收到与超出 GC 超额限制相关的 oome 错误。在 Linux 上,每当我手动运行 GC 时,它就会下降到不到 100m。

GC 看起来确实像在 Windows 上运行得那么好。

在 Windows 上,应用程序在负载更大的情况下运行得更好。

我如何找到这背后的原因?

我正在使用 jdk1.6.0.13

最小堆:512m 和最大堆 1024m

编辑:

  • 您在 Windows 和 Linux 上使用相同的 JVM 版本吗?

    • 是。1.6.0.13。
  • 您在两个系统上使用相同的垃圾收集器吗?

    • 我注意到 jconsole 中的 gc 是不同的。
  • 您在两个系统上使用相同的 Web 容器吗?

    • 是的,Tomcat。
  • 您的网络应用程序是否依赖本机库?

    • 不确定。我用的是tomcat+spring+hibernate+jsf。
  • 这两个平台上的 Web 应用程序配置还有其他差异吗? 否

  • 与 OOME 相关的错误消息到底是什么?

    • java.lang.OutOfMemoryError:超出 GC 开销限制
  • 您的 Web 应用程序在 Linux 上开始行为不端/报告错误需要多长时间?

    • 在我让其运行 3 小时后,可以看到使用模式的差异。该错误大约在一天或两天后出现,因为那时平均内存使用量约为 900 MB。

i tried to compare my java web app behaviour on 32 bit windows and 64 bit linux.

When i view the memory usage via jconsole i find very different graph of memory usage.
On windows the appl never touches 512m.
However when i run on linux 64bit with 64 bit VM the memory keeps invcreasing gradually and reaches peak value about1000m very quickly and i also get oome error related to GC over head limit exceeded. on linux whenever i do manual run GC it drops below to less than 100m.

Its like the GC does seem to run so well as it does on windows.

On windows the app runs better with even more load.

How do i find the reason behind this?

Iam using jdk1.6.0.13

min heap:512m and max heap 1024m

EDIT:

  • Are you using the same JVM versions on both Windows and Linux?

    • yes.1.6.0.13.
  • Are you using the same garbage collectors on both systems?

    • I noticed in jconsole and i see that the gc are different.
  • Are you using the same web containers on both systems?

    • yes.Tomcat.
  • Does your webapp rely on native libraries?

    • Not sure. I use tomcat+spring+hibernate+jsf.
  • Are there other differences in the configuration of your webapp on the two platforms?
    No

  • What exactly was the error message associated with the OOME?

    • java.lang.OutOfMemoryError: GC overhead limit exceeded
  • How long does it take for your webapp to start misbehaving / reporting errors on Linux?

    • The difference in usage pattern is seen after i leave it running for say 3hrs. The error appears after like a day or 2 days since by then avg memory usage is seen around 900 mb mark.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只为一人 2024-09-18 22:35:53

64 位 JVM 自然会比 32 位 JVM 使用更多的内存,这是可以预料的(毕竟,内部指针的大小是其两倍)。从 32 位迁移到 64 位时,您无法保持相同的堆设置并期望获得相同的行为。

如果您的应用程序在 32 位 JVM 上以 512m 的速度运行良好,则没有任何理由使用 64 位 JVM。这样做的唯一理由是利用巨大的堆大小。

请记住,在 64 位操作系统上运行 32 位 JVM 是完全有效的。两者没有关系。

A 64bit JVM will naturally use a lot more memory than a 32bit JVM, that's to be expected (the internal pointers are twice the size, after all). You can't keep the same heap settings when moving from 32bit to 64bit and expect the same behaviour.

If your app runs happily in 512m on a 32bit JVM, there are no reasons whatsoever to use a 64bit JVM. The only rationale for doing that is to take advantage of giant heap sizes.

Remeber, it's perfectly valid to run a 32bit JVM on a 64bit operating system. The two are not related.

尐籹人 2024-09-18 22:35:53

有太多的未知数无法解释这一点:

  • 您在 Windows 和 Linux 上使用相同的 JVM 版本吗?
  • 您在两个系统上使用相同的垃圾收集器吗?
  • 您在两个系统上使用相同的 Web 容器吗?
  • 您的网络应用程序是否依赖于本机库?
  • 这两个平台上的 webapp 配置还有其他差异吗?
  • 与 OOME 相关的错误消息到底是什么?
  • 您的 Web 应用程序在 Linux 上开始行为不端/报告错误需要多长时间?

另外,我同意@skaffman...不要使用 64 位 JVM,除非您的应用程序确实需要它。

There are too many unknowns to be able to explain this:

  • Are you using the same JVM versions on both Windows and Linux?
  • Are you using the same garbage collectors on both systems?
  • Are you using the same web containers on both systems?
  • Does your webapp rely on native libraries?
  • Are there other differences in the configuration of your webapp on the two platforms?
  • What exactly was the error message associated with the OOME?
  • How long does it take for your webapp to start misbehaving / reporting errors on Linux?

Also, I agree with @skaffman ... don't use a 64bit JVM unless your application really requires it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文