Design and Implement a Simple Java GC (Java 7+)


  • 8

    Please design Java Garbage Collector and implement it.

    Several key features to look for:

    1. A heap which represents JVM when a Java program starts.
    2. At least three parts in the heap that represent Eden Space, Tenured Space and Perm Space.
    3. Different rounds of garbage collecting in these above three spaces (checking all objects to see if they have any live references at all, if not, kill them, reclaim the allocated memory, otherwise, move them to later spaces..)

  • 0
    I

    @fishercoder is there a specific time to live that we need to keep track of ?


  • 0
    This post is deleted!

  • 0

    fishcoder, Can we assume that roots were defined in advance?Also should collector collpases reclaimed memory for optimization reasons? I noticed that they specifies only one young generation - Eden. Can we consider that when Eden space is full, data is moved to Tenured space?


  • 0

    @elmirap

    1. we can predefine the roots.
    2. what do you mean by that? a bit more illustration please? :)
    3. Exactly, that's one assumption you definitely want to bring up with your interviewer. It's usually how JVM GC works.

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.