• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

GC

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not possible to turn garbage collection off -true /False
i think it is true becoz u have java -noasyncgc
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi shan
i agree with u.
it is true.
The garbage collector runs in a low-priority thread and runs either synchronously or asynchronously depending on the situation and the system on which Java is running. It runs synchronously when the system runs out of memory or in response to a request from a Java program.
The Java garbage collector runs asynchronously when the system is idle, but it does so only on systems, such as Windows 95/NT, that allow the Java runtime environment to note when a thread has begun and to interrupt another thread. As soon as another thread becomes active, the garbage collector is asked to get to a consistent state and terminate
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's false. First off, -noasyncgc is no longer available in jdk 1.2+. More importantly, turning off asynchronous GC does not turn off GC completely. GC still runs in response to System.gc(), and still runs when memory runs out. It just doesn't run at other times.
I guess kris and I are really saying the same thing, except we interpret the question differently. To me, if significant parts of the garbage collection system still work, then you haven't "turned off GC" - you've only turned off part of GC. That's not enough to make the answer true, in my opinion.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does it mean garbage collection cannot be turned off completely??
i would also like to know whether iam correct :
there was this question in mock exam
a)it is not possible to predict when gc will happen
b)it is not possible to cause gc to run at any point.
c)the applications programmer must allocate and free memory.
d)it is not possible to force gc reliably
e)gc runs on low memory-i think that is what it said if iam correct
i think the answer is a) and d)
b) is wrong because we can force gc to run at any point even though you can't be sure(reliable) of getting it.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right - garbage collection can never be turned off completely.
As for the exam question, it's another vaguely-worded question with no definite answer. Here are my thoughts:
a) Sometimes it is possible to predict it, but many times it's not. Probably the intended answer is true, it's not possible.
b) The "at any point" can ber interpreted two ways: 1) It's never possible to cause gc to run, or 2) It's not possible to guarantee that gc will run whenever you want it to. The first is false; the second is true. I'm inclined to the first interpretation.
c) definitely false
d) definitely true
e) What it probably said is that gc runs when memory is low or runs out. This is true. There's no guarantee that it will successfully free memory, but it will certainly try.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks jim.
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic