Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem work with System.gc (Explicit garbage collection)

  Asked By: David    Date: Feb 24    Category: Java    Views: 2725
  

I work with jboss 3.2.6 . In my application, I want
call garbage collector explicitly. But I don't have a
mechanism that when call System.gc
If anybody have any suitable mechanism for time of
this call please tell me.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Emma Campbell     Answered On: Feb 24

As long as I know, you don't necessarily need to call garbage  collector explicitly

 
Answer #2    Answered By: Kellie Bishop     Answered On: Feb 24

It is good know that you should never relay on calling
garbage collector exprlictily. So you must know that
methods that java provides are requests and not
demands. The virtual machine will do its best to do
what you ask, but there is no guarantee that it will
comply.
Anyway, you can also try caling GC through Runtime
class. For example:

Runtime r = Runtime.getRuntime();
r.gc(); // this is an alternate to System.gc()

 
Answer #3    Answered By: Mona Wagner     Answered On: Feb 24

If you want global information (e.g. your total memory or -Xm' are ok?)
call java with "-verbose:gc -Xloggc:/tmp/gc.log" and you will get a lot of
knowledge on how your system  works. Give "-incgc" a try, but most of the
time it sucks!

If you wana detailed information maybe you can use a memory profiler. Also
Java's system library has 'totalMemory()' and 'freeMemory()' witch can
help too.

 
Didn't find what you were looking for? Find more on Problem work with System.gc (Explicit garbage collection) Or get search suggestion and latest updates.




Tagged: