Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javacaps mock 1 Q:11

 
Haining Mu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
11. Which statements about garbage collection are true?
A) The garbage collector runs in low memory situations
B) You can run the garbage collector when ever you want.
C) When it runs, it releases the memory allocated by an object, which is no more in use.
D) Garbage collector immediately runs when you set the references to null.

Answer: A.C
feel a little bit not comfortable with A, can somebody explain a little bit? does its wording has problem?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When memory gets "low" (however low is defined in the JVM) then garbage collection will automatically be kicked off.
 
Haining Mu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Paul:
When memory gets "low" (however low is defined in the JVM) then garbage collection will automatically be kicked off.

so, if memory NOT gets 'low', gc will NOT be suggested to run unless explicitly call?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GC always runs as a low priority thread so if nothing else is happening, garbage collection can run even if memory is not "low".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic