简体   繁体   中英

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. While processing data i did not provide any heap max size parameter. My program continuously consuming memory and it is not calling java GC. To process data only 2GB memory is needed. Can anyone give detail when GC called by JVM? or is it Necessary to provide heap max size parameter?

I am using 64bit system with 64gb RAM for processing of large data. 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.

My program continuously consuming memory and it is not calling 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.

To process data only 2GB memory is needed.

You should be having minor GC collections, unless you only use large arrays and very little small objects. ie your eden space never fills up.

Can anyone give detail when GC called by JVM?

When the current eden size is reached, it performs a minor GC. If the GC decides more memory is needed and the maximum hasn't been reached it will increase the heap available.

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. 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).

Can anyone give detail when GC called by JVM?

It is called when the JVM thinks it is necessary. Typically, that is when the Eden space (where most new objects are created) is too full. 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. The actual decision making is dependent on the kind of GC your JVM is using. (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. Rather it will attempt to either optimize for minimum GC pause time, or optimize for maximum throughput.

So, when the GC runs, the JVM is reluctant to reduce the size of the heap. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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