Java - x32和x64之间的奇数内存消耗 [英] Java - Odd memory consumption between x32 and x64

查看:99
本文介绍了Java - x32和x64之间的奇数内存消耗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在分析我的应用程序的x64版本,因为内存使用率非常高,所有这些似乎来自JavaFX MediaPlayer,我正确地释放了监听器和事件处理程序。

I've been profiling the x64 version of my application as the memory usage has been outrageously high, all of it seems to be coming from the JavaFX MediaPlayer, i'm correctly releasing listeners and eventhandlers.

这是鲜明的对比。

开始时的x32版本

现在开始时的x64版本

And now the x64 version at start

x32版本保持在256mb以下,而x64将在演出中拍摄;这是两个都可以播放他们的播放列表。

The x32 version stays below 256mb while the x64 will shoot over a gig; this is while both are left to play through their playlist.

所有代码都是相同的。

All the code is the same.

JDK:jdk1.8.0_20

JDK: jdk1.8.0_20

JRE:jre1.8.0_20

JRE: jre1.8.0_20

两者上的VM参数

-XX:MinHeapFreeRatio=40 -XX:MaxHeapFreeRatio=70 -Xms3670k -Xmx256m -Dsun.java2d.noddraw=true -XX:+UseParallelGC

在另一个x64 Java上发生同样的问题申请

Same issue occurring on another x64 Java application

这是一个错误还是我忽略了什么?

Is this a bug or am I overlooking something?

推荐答案

你看到的是什么是运行进程的整个JVM的内存使用情况。 -Xmx256m设置仅限制应用程序可用的最大堆空间(并且JVM会强制执行该操作)。在堆空间之外,JVM可以使用额外的内存用于其他目的(我相信我会在下面的列表中遗漏一些内容):

What you are seeing is the memory usage of the entire JVM running your process. The -Xmx256m setting only limits the maximum heap space available for your application to allocate (and the JVM would enforce that). Outside of heap space, the JVM can use additional memory for a host of other purposes (I am sure I will miss a few in the list below):


  • PermGen,现已被Metaspace取代。根据文档,没有默认值限制:

-XX:MaxMetaspaceSize=size
Sets the maximum amount of native memory that can be allocated for class metadata. By default, the size is not limited. The amount of metadata for an application depends on the application itself, other running applications, and the amount of memory available on the system.


  • 堆栈空间(使用的内存=(线程数)*堆栈大小。您可以控制这与-Xss参数

  • Stack space (memory used = (number of threads) * stack size. You can control this with the -Xss parameter

    堆外空间(在代码中使用ByteBuffers,或使用第三个pary库,如EHCache,反过来使用堆外内存)

    Off-heap space (either use of ByteBuffers in your code, or use of third pary libraries like EHCache which would in turn use off-heap memory)

    JNI代码

    GC(垃圾收集者需要自己的内存,它也不是堆的一部分,可以根据使用的收集器和应用程序内存使用情况而有很大差异)

    GC (garbage collectors need their own memory, which is again not part of the heap and can vary greatly depending on the collector used and the application memory usage)

    在你的情况下,你看到内存使用几乎翻倍,当你从32位移动到64位JVM时,可能会更放松的Metaspace分配。使用 -XX:MaxMetaspaceSize = 128m 可能会使64位JVM的内存使用率降至512MB以下。

    In your case, you are seeing the "almost doubling" of memory use, plus probably a more relax Metaspace allocation when you move from a 32bit to a 64bit JVM. Using -XX:MaxMetaspaceSize=128m will probably bring the memory usage down to under 512MB for the 64bit JVM.

    这篇关于Java - x32和x64之间的奇数内存消耗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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