简体   繁体   English

如果未指定最大堆大小,则在 64 位系统上调用 java GC 时

[英]When java GC call on 64 bit system if max heap size not specified

I am using 64bit system with 64gb RAM for processing of large data.我正在使用带有 64GB RAM 的 64 位系统来处理大数据。 While processing data i did not provide any heap max size parameter.在处理数据时,我没有提供任何堆最大大小参数。 My program continuously consuming memory and it is not calling java GC.我的程序不断消耗内存,它没有调用 java GC。 To process data only 2GB memory is needed.处理数据只需要 2GB 内存。 Can anyone give detail when GC called by JVM?任何人都可以在 JVM 调用 GC 时提供详细信息吗? or is it Necessary to provide heap max size parameter?还是必须提供堆最大大小参数?

I am using 64bit system with 64gb RAM for processing of large data.我正在使用带有 64GB RAM 的 64 位系统来处理大数据。 While processing data i did not provide any heap max size parameter.在处理数据时,我没有提供任何堆最大大小参数。

The default heap size for a 64-bit JVM is 1/4 of main memory or 16 GB in your case.在您的情况下,64 位 JVM 的默认堆大小是主内存的 1/4 或 16 GB。

My program continuously consuming memory and it is not calling java GC.我的程序不断消耗内存,它没有调用 java GC。

I would be very surprise if the GC is not running if you didn't tune it at all regardless of the maximum size.如果 GC 没有运行,如果您根本不调整它而不管最大大小,我会感到非常惊讶。

To process data only 2GB memory is needed.处理数据只需要 2GB 内存。

You should be having minor GC collections, unless you only use large arrays and very little small objects.你应该有次要的 GC 收集,除非你只使用大数组和很少的小对象。 ie your eden space never fills up.即您的伊甸园空间永远不会填满。

Can anyone give detail when GC called by JVM?任何人都可以在 JVM 调用 GC 时提供详细信息吗?

When the current eden size is reached, it performs a minor GC.当达到当前 eden 大小时,它会执行次要 GC。 If the GC decides more memory is needed and the maximum hasn't been reached it will increase the heap available.如果 GC 决定需要更多内存并且尚未达到最大值,它将增加可用堆。

or is it Necessary to provide heap max size parameter?还是必须提供堆最大大小参数?

Only if you want it to use less memory (but this is likely to be slower)仅当您希望它使用更少的内存时(但这可能会更慢)

If you want to limit the amount of memory that the JVM uses, it is necessary to provide a max heapsize option.如果要限制 JVM 使用的内存量,则需要提供 max heapsize 选项。 If you don't do this, the JVM will use a default heap size, which may be half the available RAM (depending on your JVM type and version).如果您不这样做,JVM 将使用默认堆大小,它可能是可用 RAM 的一半(取决于您的 JVM 类型和版本)。

Can anyone give detail when GC called by JVM?任何人都可以在 JVM 调用 GC 时提供详细信息吗?

It is called when the JVM thinks it is necessary.当 JVM 认为有必要时调用它。 Typically, that is when the Eden space (where most new objects are created) is too full.通常,那是 Eden 空间(创建大多数新对象的地方)太满的时候。 It can also happen if you attempt to allocate an object that is too big for Eden space anyway, and the tenured space there the object needs to be allocated is too full.如果您尝试分配一个对于 Eden 空间来说太大的对象,并且该对象需要分配的永久空间太满,也会发生这种情况。 The actual decision making is dependent on the kind of GC your JVM is using.实际决策取决于您的 JVM 使用的 GC 类型。 (And it is opaque; ie not specified / documented in any published documentation. And probably irrelevant to the problem you are actually trying to solve.) (而且它是不透明的;即没有在任何已发布的文档中指定/记录。并且可能与您实际尝试解决的问题无关。)

The GC does not have minimize memory usage as a primary goal for optimizing performance. GC 没有将最小化内存使用作为优化性能的主要目标。 Rather it will attempt to either optimize for minimum GC pause time, or optimize for maximum throughput.相反,它将尝试针对最小 GC 暂停时间进行优化,或者针对最大吞吐量进行优化。

So, when the GC runs, the JVM is reluctant to reduce the size of the heap.因此,当 GC 运行时,JVM 不愿意减小堆的大小。 This is because the GC tends to run more efficiently if the heap size is significantly larger than your application's working set of reachable objects.这是因为如果堆大小明显大于应用程序的可访问对象的工作集,则 GC 往往会更有效地运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM