Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Control the garbage collector

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-07-2010
Member
 
Join Date: Mar 2010
Posts: 383
Control the garbage collector
  

Hello,
My question is simple, yet the commend is mandatory to break through the garbage collector to relieve a lot of room? I am working on an app where I found much appeal in gc theoretically unnecessary because the JVM starts automatically, but I still fear by removing all broken because the treatments are very important. Can we control the garbage collector manually? Any more discussion on this is appreciated. Thank you.

Reply With Quote
  #2  
Old 23-07-2010
Member
 
Join Date: Dec 2009
Posts: 292
Re: Control the garbage collector

Yes, calling the garbage collector do not guarantee that it will execute. So I think that it is unnecessary to do so, the jvm will take care of everything. If I am not wrong then you can not control the garbage collector manually.
Reply With Quote
  #3  
Old 23-07-2010
Member
 
Join Date: Nov 2009
Posts: 518
Re: Control the garbage collector

Personally I think that calling explicitly the GC is a mistake. I strongly advise you to launch your application with the option of the JVM -verbose: gc. This enables you to have traces of the passage of the GC with its execution time and memory actually released (do a test and preferably not in production). Often an explicit call to GC is heavy and does not necessarily free memory.
Reply With Quote
  #4  
Old 23-07-2010
Member
 
Join Date: Apr 2008
Posts: 242
Re: Control the garbage collector

Before changing your program I advise you to run with the option -XX: + DisableExplicitGC, which will indicate to the JVM to ignore any explicit calls to the GC. It would be best to test by combining with -verbose: gc and with the same data (if available) to see where the memory usage in both cases. I'm talking about the JVM from Sun, if you use another JVM deferred up to its documentation to see if there are similar parameters.
Reply With Quote
  #5  
Old 23-07-2010
Member
 
Join Date: Dec 2009
Posts: 296
Re: Control the garbage collector

I agree with what has been said previously. However, I have met very specific cases where the call the garbage collector using the static method System.gc () helped me enormously. The example I encountered was an algorithm for data mining (search for sequential patterns for lovers ) Which developed a tree prefixed floor by floor. At each step, I emptied some of my structures by way of memory optimization in order to keep new data in memory and I needed an entire floor of the memory is cleared before tackling the next stage. In this situation, the call to gc was inevitable because, although freed references to my objects, the latter were still in memory. The explicit call to gc is for use only in cases of "extreme" and very special, but it is all the same good to know how to use it in case. I no longer have the link handy but I remember reading a very good articles (on development) on the management policy of the memorial made by the Sun jvm.
Reply With Quote
  #6  
Old 23-07-2010
Member
 
Join Date: Mar 2010
Posts: 197
Re: Control the garbage collector

Here is the code
Code:
StatCacheManager.purgeCacheIfNecessary (); 
List bkenst StatDAO.getInstance = (). 
FindStatResults (inct, stdt, edt); 
Collection FSRS FrontStatResultHelper.build = (stdt, edt, bkenst, inct)
System.gc ();
List rs = new ArrayList (FSRS);
Reply With Quote
  #7  
Old 02-08-2010
Member
 
Join Date: Dec 2009
Posts: 204
Re: Control the garbage collector

Remember when not even that, in addition to being heavier when it is performed, the line System.gc () will not necessarily throw the garbage collector at that time, the midlet may launch later ... Generally calls System.gc can be avoided, for example by destroying hand objects (by making references to null) so to increase his chances of a call to gc as and when measured from a deletion but usually it takes as far as possible avoid creating eds programs taking up a lot of main memory, as it is a critical resource and very limited in a computer.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Control the garbage collector"
Thread Thread Starter Forum Replies Last Post
JAVA - What is garbage collection Bhim Software Development 5 28-04-2011 01:13 PM
Tuning JVM and Garbage Collector SoftWore Tips & Tweaks 1 23-07-2010 03:24 PM
Java - help with Garbage Collection Messenger Software Development 4 23-07-2010 10:18 AM
What is the Garbage Collection in PHP? Emma.J Software Development 5 04-03-2010 12:40 AM
What are the two kinds of Garbage Collectors for C++? KALYAN23 Software Development 3 10-11-2009 03:58 PM


All times are GMT +5.5. The time now is 07:24 AM.