• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to call garbage collector implicitly...  RSS feed

 
Raveendra Mutyala
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me, How to call a garbage collector implicitly other than using System.gc();
 
jeevan saini
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
urai pandiga,
what a stupid question did u ask us
nobody will respond to u.
stop sending such question
and buy one complete refernce and learn some tips from ur frnz like jeens
 
Sirish Kumar Gongal Reddy
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The Garbage collector will invoke automatically for every reggular intervals of time (i.e for every 31 sec).if you don't use your object up to that min time the grabagecollector will remove it from heap and reclaim the memory which is occupied by your object.
If you want more information about GC plz have a glance at Thinking in Java.

Thanks & Regards,
G Sirish Reddy.,
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You cannot call the Garbage Collector. By calling System.gc(), you are only suggesting to the JVM some objects might be eligible for garbage collection.

Anyway, the other way to do this is: Runtime.getRuntime().gc()
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reddy : if you don't use your object up to that min time the grabagecollector will remove it from heap and reclaim the memory which is occupied by your object.

Is it so ?

The garbage collector will reclaim the memory only when the object is not referenced by any active threads . If an active thread has reference to any of the object that will not be GC'd.

Also we cant force the JVM to do the garbage collection, even if you call System.GC() it's uncertain that the objects that are eligible for garbage collection will be removed from heap.
[ September 15, 2005: Message edited by: Srinivasa Raghavan ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jeevan saini:
urai pandiga,
what a stupid question did u ask us
nobody will respond to u.
stop sending such question
and buy one complete refernce and learn some tips from ur frnz like jeens

Jeevan,
Please try to post in english, as this thread is for international readership.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!