Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Garbage Collection - Survivor Spaces Query  RSS feed

 
Vaibhav Gargs
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going through the Java Garbage Collection process and have following queries:

1. There are two survivor spaces in Heap Memory. What is the reason for having two Survivor spaces? What would be the impact if they kept just one Survivor Space instead?

2. During GC, objects are moved from 1 survivor space to other. Why it is so? Can't it just copy the live objects in first survivor space itself? Overall, if there are 5 objects which are live will be present on the Survivor space, so, why there is an overhead of moving them from one survivor to another?
 
Campbell Ritchie
Marshal
Posts: 55747
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Where did you get that from? How do you know which versions of Java® that applies to?
 
Campbell Ritchie
Marshal
Posts: 55747
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for providing the links which seem good.
I haven't got the time to go through the Oracle link I am afraid, but both links appear to use Java7. I know there are changes in Java8, for example the PermGen disappearing, so those details are implementation‑specific. The blogspot link didn't seem to mention escape analysis whereby some local variable objects are created on the stack (Java6).

I don't know why the space is divided in two. Maybe somebody else will know.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!