aspose file tools*
The moose likes Tomcat and the fly likes Increase GC calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Increase GC calls" Watch "Increase GC calls" New topic
Author

Increase GC calls

Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 102
Hello,

I read on this forum that it is possible to increase the GC calls. However can not find how to do this in Tomcat5.5.

I opened the Tomcat5.5 Configuration Windows and went to the Java Tab. I set the maximum heap size and minimum heap size to 1024Mb (There are textfields in the bottom of the window for this).

However I can not find how to increase the GC calls. From whee can I ncrease the GC Calls? Also is this a good idea? would I be risking anything?

Thanks & Regards,
Sim085
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is nothing specific in Tomcat for doing this.

You can always suggest that the JVM run Garbage Collection (GC) with System.gc().

Do you have a reason for wanting to do this?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 102
Actually I read this on another post and got intrested because I believe it could help me solve a problem that I have been having.

Basically my application deployed on Tomcat was continuasly crashing (throwing different exceptions after some time). I now increased the Maximum Heap Size, and so far the system did not crash.

I do not think I have any memory leaks since I am not managing and database connection. All connections are managed by Hibernate (A Framework to persist objects with a relational database).

I thus assumed that my problem is comming because the garbage collection process is not running fast enough. I came to this assumption because when I use the system and load too many objects (with a small heap), the system crashes.

So basically I tought that maybe there could be an option in Java (or Tomcat) to run the GC more often.

ps: How can I know if my system has any memory leaks? Is there a tool or something?

Regards,
Sim085
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
I thus assumed that my problem is comming because the garbage collection process is not running fast enough.


Bad assumption. GC will always be run if the system can't find enough memory for a new object. If a memory exception is thrown you can be sure that the JVM has tried everything to find the space.

Bill
Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 102
So how does it explain itself that the system is now not crashing once I increased the Heap Size?

Also is there any tool that I can use to monitor the memory being used by my Application? Whit such a tool I can see if my application is eating up memory. Thuis I would know if increasing the Heap Size just postponed the problem or else solved it!

Thanks for explaining me how the garbage collection works!

Regards,
Sim085
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
So how does it explain itself that the system is now not crashing once I increased the Heap Size?


Obviously, because at some point your app needs more memory than you expected for some reason.
There are a LOT of tools for looking at memory use.
You can use the java.lang.Runtime methods such as freeMemory() to log stuff for example.
I think recent threads in the forum have covered this topic, do some searches.
Bill
Simon Joseph Aquilina
Ranch Hand

Joined: Feb 14, 2006
Posts: 102
Thanks, I definitly will

Regards,
Sim085
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Increase GC calls