Is compaction really inevitable for all GC JVM implementations?

This one says:

These pauses are the result of the inevitable requirement for a compact pile to make room. Collectors use different strategies to delay these events, but compaction is inevitable for all commercial collectors available.

I got the impression that if you keep the memory size of your application constant, then there is no need to compress the GC, in other words, this will happen only if you continue to add and collect objects. If you have a large enough pile with enough free space, why would you ever need to squeeze when you do not create any holes (i.e. do not generate garbage)?

I understand that maintaining a constant amount of memory for a Java application is not easy, but it is possible with the right profiling, bootstrap, and discipline tools.

So, is it not reasonable to assume that a Java application can work with permanent memory without any delays embedded in the GC, in other words, without GC pauses?

EDIT: By persistent memory, I mean steady state , as Ajay George mentioned, when no more objects are created or not mentioned. If you continue to create objects, you will end up running out of memory, and if you continue to delete objects, you will eventually call GC. Thus, the ultimate goal is to start, warm up, force fill the GC, and then transition to a steady state for production time.

+4
source share
3 answers

I got the impression that if you save memory your application constantly, then there is no need to compact the GC In other words, this will happen only if you continue to add and collect objects.

At the moment when your object receives a link refusal (it has the right to garbage collection), there is a possibility for compaction. This is because you start fragmenting your heap, just as your hard drive becomes fragmented.

So it is not reasonable to assume that with a permanent memory a Java application can work without any delays embedded in the GC, in other words, without GC pauses?

GC introduced delays are the result of using the used GC algorithms. It is orthogonal to the concept of having a permanent memory. Well, if you are considering the case that your application does not create or cancel object references and may have received a kind of steady state . Ideally, this is not so, since most objects are short-lived.

Having said that with the Azul Pauseless Collection algorithms, this might just be possible. There is a wonderful discussion about what's here .

+2
source

No, compaction is not really necessary, many garbage collectors are not compact, CPython can be an example, objects never move in memory.

Sealing garbage collectors do offer one big advantage - they return fragmented memory.

If you are not compact, your process memory usage is never reduced, because if there is still 16 byte None on the 4K page, it cannot be freed. A steady state does not help here, because in a garbage collection system, a steady state means that garbage is generated and recycled. Steady state equal to their number. CPython handles this through object generation (newly created objects are much more likely to become garbage).

Finally, there are incremental garbage collectors, or if you have started bleeding research, to no avail parallel garbage collectors with hardware http://www.cs.purdue.edu/homes/hosking/ismm2000/papers/heil.pdf , one commercially available http: //www.azulsystems.com/products/zing/whatisit

+1
source

I believe what they mean when they say that โ€œcompaction is inevitable,โ€ they simply mean that a good GC will eventually perform compaction for typical memory allocation patterns.

I donโ€™t know about Java specifically (and it probably depends on which JVM you use), but most languages โ€‹โ€‹will not invoke GC at all unless you allocate or free memory. Very often this happens only during allocation (since this is the only time that more free memory is required) and, of course, also when explicitly called.

So, for your rather strange definition of "stable state" when distributions do not occur and no garbage is even generated, there is no reason to refer to the GC at all if it has already completed the full assembly / compaction. Trying to squeeze a bunch, of course, would be a waste of time in this case.

0
source

Source: https://habr.com/ru/post/1447403/


All Articles