Garbage Collectors in JVM

Throughput

The percentage of total time not spent in garbage collection, considered over long periods of time.

Garbage collection overhead

The inverse of throughput, that is, the percentage of total time spent in garbage collection.

Pause time

The length of time during which application execution is stopped while garbage collection is occurring.

Frequency of collection

How often collection occurs, relative to application execution.

Footprint

A measure of size, such as heap size.

Promptness

The time between when an object becomes garbage and when the memory becomes available.

Heap is divided into generations, mostly in two

  1. young objects
  2. old objects

Different collection algorithm can be used for different part (generation) of heap, and each algorithm can be optimized based on commonly observed characteristic of that particular generation.

weak-generation-hypothesis: most objects die young

Young generation collections occur relatively frequently and are efficient and fast because the young generation space is usually small and likely to contain a lot of objects that are no longer referenced. Objects that survive some number of young generation collections are eventually promoted to the old generation. Old generation is typically larger than the young generation and its occupancy grows more slowly. As a result, old generation collections are infrequent, but take significantly longer to complete.

Garbage Collectors
j2se 5.0 includes 4 collectors. All are generational (i.e. divide heap into generations).
Memory organized into 3 generations
Young Generation Most objects are initially allocated here. Consists of an area called EDEN plus two smaller SURVIVOR spaces. Objects are initially allocated in Eden. The survivor spaces hold objects that have survived at least one young generation collection and have thus been given additional chances to die before being considered "old enough" to be promoted to the old generation.
Old Generation contains objects that have survived some number of young generation collections, as well as some large objects that may be allocated directly in the old generation.
Permanent Generation holds objects that the JVM finds convenient to have the garbage collector manage, such as objects describing classes and methods, as well as the classes and methods themselves.

minor collection: young generation collection, when young gen fills up. using configured young gen collection algorithm.
major collection: all generation collection (except may be permanent gen, which mostly never gets collected), when old gen fills up. using configured old gen collection algorithm.

compactation : if needed each gen is compacted separatly.

Advertisements

8 thoughts on “Garbage Collectors in JVM

  1. hi..i have one question..How can I force clean up for old gen for every 10 minutes?
    Do you know what code should I write in cmd line?Hope to get ur feed back as soon as possible. Thanks in advance.

  2. I’m using sun. I’m trying to use this code but it didn’t work:
    -Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000

  3. No…I only write -Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000…

    Should I add -XX:+DisableExplicitGC on ??

  4. I’m using visualvm,which I can see the graph for old gen, young gen etc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s