I’m trying to understand the generational collector and I don’t seem to have it quite right.
I think in general it works like this:
When the Eden is filled GC runs on it… any objects in Eden that are still alive with a generation count that exceeds some threshold are promoted to the next generation and the Eden space is compacted - those objects that remain in Edne have their generation count incremented. The new object is created in the available space that is reclaimed. If the new object still doesn’t fit in Eden it goes straight to the older generation which usually has a larger max size.
Is that correct? If so…
What happens when you allocate several large objects in a row… such that they are too large to fit in Eden after it is collected but too small for the VM to know to place them in the larger heap right away. Does the 2nd large object and those after it cause GCs in Eden that basically do redundant collections that don’t reclaim any/enough new Eden space yet still bump the generation count on the young objects so that they are prematurely promoted?
Or after a Eden GC does the VM track the amount of KNOWN free space in Eden… hmm no that isn’t possible, everything left in Eden could be garbage by the time the next allocation happens, so there just may be enough space, it will have to try to collect.
I’m trying to learn how to best tune both the GC parameters and object creation patterns.
E.g. I have an app that generates lots of short lived, large objects (images from motion-JPEG video frames). I had some issues with GC pauses. these mostly went away when I tried -XX:+UseConcMarkSweepGC but the video is still not 100% smooth. I wonder how I might tune the generation sizes to optimize this.
I don’t use JMF because last time I tried it didn’t work well enough and is fairly complex.