• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.gc() problem

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Boone Exam:
Which statement about g.c are true?Select all valid answers?
a>you can directly free the memory allocated by an object
b>you can directly run the g.c when I want
c>g.c informs your object when it is about to be garbage collected.
d>g.c reclaims an object's memory as soon as it becomes a candidate for garbage collection.
e>g.c runs in low memory situations.
Ans: b,c
But my answer was c,e.
If we use System.gc() ,is it g.c thread forced to run immediately but no garbage collection takes place until it is eligible by some random
manipulation of memory management?My idea was g.c thread will run when eligible only eve if we use System.gc().
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Calling System.gc() does not guarantee that a GC thread will be started, so I disagree with b.
Bill
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And e is wrong too, since there is no guarantee that this will be the case. There is no specification as how to implement the GC. Running the GC in low-memory situation can be implemented by one JVM provider but another provider may have another heuristic.
reply
    Bookmark Topic Watch Topic
  • New Topic