Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Garbage Collection - Survivor Spaces Query  RSS feed

 
Ranch Hand
Posts: 233
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?
 
Marshal
Posts: 59092
180
  • 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: 59092
180
  • 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.
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!