I'm also not an expert, but according to SCJP 5.0, the garbage collection algorithm is not guaranteed in different versions of JVM across platforms. So, you must be careful on changing parameters for the right platform.
Also, according to the same SCJP, you don't need to worry about System.gc(), because it is actually DUMMY. (perhaps not in the older versions) System.gc() just tells the JVM that "you want to run garbage collection", that doesn't mean the JVM will really run. Finally, it is still up to JVM to decide when is the "appropriate" time to kick off the collector. Harry Bill Bailey-2 wrote: > > I'm not an expert on the algorithms, especially since they get tweaked and > improved with each release, but in general Java tries to keep the > available heap in some acceptable range. When the amount of free to used > memory reaches some threshold, it runs garbage collection. It is possible > that the amount of memory used can spike ... I've seen this too ... but > Java seems to eventually do the right thing. > > > > There are some non-standard, possibly undocumented (or at least well > hidden) parameters that allow you to tune garbage collection, but you > should do it with caution ... the defaults work well for most apps and if > you make the wrong changes you can definitely make your situation worse. > Below is a link to a pretty detailed article on the JDK 5.0 collector ... > it should be reasonably similar to the one for JDK 1.4 and JDK 6.0 so it > might shed some light. It also includes some of the aforementioned > parameters that you can use to tune garbage collection should you feel > brave. > > > > http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html > > > > Also, you can used System.gc() to tell the JVM you think it should run > garbage collection, but it is generally discouraged since the JVM usually > has more information to make that decision than your app. Also, > technically this is just a hint to the JVM and does not have to actually > result in a GC run, but I think in practice the current implementation > always does do a garbage collection run when you call it. > > > > Hope this helps some. > > > Bill > > > > ________________________________ > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Scott Battaglia > Sent: Monday, October 01, 2007 3:09 PM > To: Yale CAS mailing list > Subject: Re: Memory used by CAS > > > > I believe Java decides when to actually free the memory based on when it > needs to, not when there's objects that can be freed. I used to have some > good documentation on when Java's garbage collection runs. Does anyone > have any good pointers to explanations on how Java's garbage collection > runs? > > -Scott > > On 10/1/07, Dominika Tkaczyk <[EMAIL PROTECTED]> wrote: > > Scott Battaglia napisaĆ(a): > >> Are you actually seeing out of memory exceptions or are you just worried >> that free memory goes low? If the memory goes low and then is garbage >> collected that is fine. >> >> Otherwise, I would see what those Hashmap entries are holding on to. My >> guess would be tickets. You could always shorten the ticket expiration >> time >> and run the cleaner more frequently. > > Hi Scott, > sorry for the delay of my answer. > > So far, there were no memory exceptions. I am worried, because I thought > that garbage collector should clean the memory periodically, and not when > the free memory is very low. Maybe there is a way to tell it to do so? > > Anyway, I admit: maybe I am just being too careful with this. > > Regards, > Dominika > _______________________________________________ > Yale CAS mailing list > [email protected] > http://tp.its.yale.edu/mailman/listinfo/cas > > > > > -- > -Scott Battaglia > > LinkedIn: http://www.linkedin.com/in/scottbattaglia > > > _______________________________________________ > Yale CAS mailing list > [email protected] > http://tp.its.yale.edu/mailman/listinfo/cas > > -- View this message in context: http://www.nabble.com/Memory-used-by-CAS-tf4434558.html#a13015033 Sent from the CAS Users mailing list archive at Nabble.com. _______________________________________________ Yale CAS mailing list [email protected] http://tp.its.yale.edu/mailman/listinfo/cas
