Please design Java Garbage Collector and implement it.
Several key features to look for:
- A heap which represents JVM when a Java program starts.
- At least three parts in the heap that represent Eden Space, Tenured Space and Perm Space.
- 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..)
@fishercoder is there a specific time to live that we need to keep track of ?
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?
- we can predefine the roots.
- what do you mean by that? a bit more illustration please? :)
- Exactly, that's one assumption you definitely want to bring up with your interviewer. It's usually how JVM GC works.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.