dbeja
dbeja

Reputation: 376

How to find memory leak with com.opensymphony.oscache on legacy java application

I have an old legacy Java application that several times per week just starts to be very slow and I have to restart Tomcat.

I checked New Relic Top Transactions and Error logs but I can't find the source of the problem, it seems the top transactions are more a consequence than a source of the problem.

So, I suppose it could be a memory leak and I did a heap dump and tried to analyze it on Eclipse Memory Analyser but I'm having difficulties in identifying the memory leak and if it is really a memory leak.

It seams the problem suspect 1 is com.opensymphony.oscache.web.ServletCache.

These are some of the results of Memory Analyser:

Summary

Histogram

Problem Suspect 1

Also, this is VisualVM monitor:

VisualVM Monitor

Thank you! Any help or guidance with this would be very helpful!

This is oscache.properties file:

cache.memory=true
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener
cache.path=/home/oscache/tb

Upvotes: 1

Views: 1163

Answers (2)

Hus Mukh
Hus Mukh

Reputation: 144

I would suggest to use trial version of YourKit Java Profiler ,it will give you much more detail about your legacy application code. Here is link : I used this tool back in 2014 as a trial version to detect memory leaks in a Web Application based on struts 2 and Hibernate.

Your Kit

Upvotes: 0

Abdul Rahman
Abdul Rahman

Reputation: 446

Few things that I would suggest to get way with the issue.

Use disk caching instead of memory cache if your use cases lets you to:

In the configuration file for oscache

cache.memory=false
cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.DiskPersistenceListener
cache.path=/opt/myapp/cache
cache.capacity=1000

If the disk cache is not recommended try reducing the cache capacity

cache.capacity=1000

Please provide the configuration details of the oscache for a better review if possible.

Update

The HashDiskPersistenceListener is used when the property cahce.memory=false

We have two options to try out

1) provide a value for cache capacity

cache.capacity=1000 #or a value that covers the usecase

2) make the cache use the disk persistance

cache.memory=false

Upvotes: 1

Related Questions