Garbage collection in testing – Perm Generation

When the garbage collector runs all referenced objects in Eden-Space and From-Survivor are copied into the To-Survivor. During a non-functional testing operation objects that already have been kept for some time in the Survivor, spaces are moved into the Old-Generation. After that Eden-Space and From-Survivor are emptied and From- and To- Survivor spaces switch their functions. Every Industry prefer using a quality QA process while launching application and websites to ensure an effective usage and results.

Are more objects referenced than fit into From-Survivor the remaining objects are directly moved into the Old-Generation? After garbage collection of the Young-Generation is finished both Eden-Space and To-Survivor are empty.

Garbage collection in Old- and Permanent- Generations

For clean-up of the Old- and Perm- generations a mark-and-sweep algorithm is used. During the mark phase all objects that are referenced by active objects (for example active thread objects, system classes, local variables, pending exceptions, references of the native stack). The removal of the unmarked objects takes place in the sweep phase. After completion of the sweep phase the markings are removed. The memory is now fragmented. During the compaction phase all remaining objects are moved to the beginning of the generation in order to get a continuous free memory region. This simplifies the allocation of memory for new objects.

TODO: describe other strategies

Parallel GC

Concurrent Mark Sweep

Parallel Compaction

Analysis of the memory utilization

After you decided for the initial configuration for heap and garbage collector you will use a load tool to put your application under realistic load (depending on your application this takes usually 8-10 hours). In order to decide for improvements you need to analyse the memory utilization under load. Many monitoring tools also provide monitoring for the Java memory utilization. Call me old-fashioned but I do not trust them. Many of them have weird algorithms to calculate the values you are dependant on for your optimization. I have seen their inaccuracy so many times. Therefore I recommend to log the garbage collector information to a logfile (usually you will do this anyway). After your test run is complete you extract the data for your analysis from the logfile.

important: look at the frequency and time consumed by gc

JVM configuration in testing companies prefer for additional logging about the heap utilization

The JVM provides a lot of different options to provide log information about heap utilization and garbage collector performance.


get detailed information about GC measures and durations. Also required when additional options for GC logging are configured


add timestamps at the beginning of the Gc entries


use a dedicated logfile for Gc information


extract size of young an old generation before and after gc, total heap, time consumption


more information regarding heap size before and after gc


adds tenuring information if you want to analyse the sizes of Eden- and Survivor-Spaces


add heap usage and capacity with timestamps


add thread local allocation buffers (TLAB)



What do you think?

200 points
Upvote Downvote

Written by viralmagfeed


Leave a Reply

Your email address will not be published. Required fields are marked *





Progressive Web Apps

What to Keep in Mind While Designing Progressive Web Apps

annual physical checkups

The Importance of Annual Health Checkups – Why You Need to Do It