• Post Reply Bookmark Topic Watch Topic
  • New Topic

GC Kill  RSS feed

 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be silly question but some silly person ask this in Interview
Is it possible to kill GC in Java programatically?

what could be advantage of doing this?
Shrinivas
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You cannot kill a GC programmatically. The interviewer is expecting some answer like:


The garbage collection cannot be forced. The garbage collector runs in low memory situations. When it runs, it releases the memory allocated by an unreachable object. The garbage collector runs on a low priority daemon (background) thread. You can nicely ask the garbage collector to collect garbage by calling System.gc() but you can�t force it.


Note: The only way you kill a GC is when you exit your application. System.exit();
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So then System.exit() would be a programatic way of desttroying the GC?
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!