garbage collection in tomcat

55 views
Skip to first unread message

Joshua Kim

unread,
Nov 16, 2020, 10:16:30 AM11/16/20
to DSpace Technical Support
Hi,

I am Joshua Kim from University of Delaware. I am new to DSpace. We have had some issue in garbage collection in Tomcat. How would any of you manage garbage collection regularly? Restart Tomcat every week or something else? 

Shaun donovan

unread,
Nov 16, 2020, 11:38:52 AM11/16/20
to Joshua Kim, DSpace Technical Support

Hi Joshua.

Garbage Collection in the JVM happens automatically and can be controlled by the switches that we use to start the JVM (in this case DSpace). It is a very complex and individual process. What I mean by this is that what works well on one installation will not necessarily work on another installation.

JVM tuning (which includes GC tuning) depends on the version of Java that you are using. There are many tutorials available on this subject, but all of them say the same basic thing. You have to start tuning, test, tweak, test, tweak, test ........... It is a long and repetitive process.

The go-to answer is to give the JVM more memory, and although this will generally work, it is not the right thing to do. You should set up some form of monitoring (we use the JMX plugin on Zabbix to monitor many JVM metrics), but things like PSI-Probe are very useful for troubleshooting.

I have found the following configuration to work well with DSpace 6.3 running on Java 8:

CATALINA_OPTS=-server \
 -Xms4096m \
 -Xmx4096m \
 -XX:+UseG1GC \
 -XX:MaxGCPauseMillis=500 \
 -Djava.awt.headless=true \
 -Dfile.encoding=UTF-8 \

I believe that it is much better to use CATALINA_OPTS as opposed to JAVA_OPTS as this separates the server configuration (tomcat) from the CLI configuration (used for cron jobs and other command line interface tools).

This configuration tells tomcat to use 4GB of heap memory (this implies that you should have at least 8 GB of memory in your server), and to use the G1GC garbage collector with a target of a 500 millisecond pause for garbage collections. Although this works well for me, it may not work for you at all, but I believe that it could be a good starting point for you.

Hope this helps.

Kind Regards.

Shaun.


On 2020/11/13 14:42, Joshua Kim wrote:
Hi,

I am Joshua Kim from University of Delaware. I am new to DSpace. We have had some issue in garbage collection in Tomcat. How would any of you manage garbage collection regularly? Restart Tomcat every week or something else? 
--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/b819fe31-f334-456e-9575-d5077c4d7a56n%40googlegroups.com.

Mark H. Wood

unread,
Nov 16, 2020, 11:42:18 AM11/16/20
to DSpace Technical Support
We do weekly server restarts here. (This also ensures that the daily
drizzle of Gentoo Linux package updates is taken up by all processes
within a week.)

We are subject to a corporate security scanner that hammers our sites
once a month. It seems to leave a lot of uncollectable garbage
behind, sometimes filling the heap 100%. So we also use 'monit' to
attempt a connection every few minutes, and kill/restart Tomcat if it
doesn't get a satisfactory response.

'monit' is also watching our available storage and will send me a
message when it runs low, also usually due to those scans and the
flood of log records that they create.

We also use 'munin' to record periodic samples of things like storage
utilization, web response times, concurrent database sessions, etc.
It makes nice graphs for spotting trends and developing problems.

Psi Probe is sometimes handy for observing current Tomcat activity and
memory usage.

--
Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu
signature.asc
Reply all
Reply to author
Forward
0 new messages