Wednesday, 28 November 2018

Garbage collector process in java

Courtesy : https://www.youtube.com/watch?v=UnaNQgzw4zY


Eden:
All new object

S1: one Eden is full, Minor CG , unrefrenced Eden objected are marked and sweep and later moved(compacted to S1)

So after one minor CG(Eden and S2 will be free)

S2: now when again eden is full, Minor GC kicks in this time on Eden and S1 space,
Unreference object from Eden and S1 are marked and







Serials: STOPS the work
Concurrent: Stops App only for mark step, doenst wait for Old generation to be full, after marking, it runs along with app, performing sweep and compact task

Parallel: uses multiple GC threads, but its stop the world/App, runs only after % of Old generation is full, it stops the app, but uses multple GC,

Best: CMS


ArraLIst Vs Linked List


The difference can be seen in underlying implementation and below time complexity.

LinkedList also implements Queue, hence gets the properties of Queues, (FIFO),
main difference is in traversal, in LinkedList you have to traverse link by link, hence get operation is
of O(n).

The time complexity comparison is as follows: 
arraylist-vs-linkedlist-complexity