Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectorparser fix - Possible memory leak - The size of LRUCache can grow above the maxCacheSize limit calling the put method concurrently #197

Open
wants to merge 1 commit into
base: jboss-1.5.5-x
Choose a base branch
from

Conversation

AlerantAppNGIN
Copy link

I do not know whether this is the correct way of communicating an issue or not, so pardon me in advance.

We use Artemis ActiveMQ version 1.1.0-wildfly-017 in production and recently we have encountered OOM exception in one of our server log. We recorded a HPROF dump and we could trace back the issue to LRUCache which stored more than 900.000 entries even though that the maxCacheSize is set to 100.

The LRUCahce uses LinkedHashMap which is not thread-safe. So putting new entries concurrently in the map could render removeEldestEntry ineffective because it is called after put is called (and we had put calls very close to each other in time).

We were able to reproduce this issue and then we made this slight code change (wrapping the LRUCache into a synchronized map in SelectorParser.java). We tested the solution and we saw that the size of the map never grew above the maxCacheSize limit.

A sidenote:
I serched for issues similar to ours and came across this one: https://issues.apache.org/jira/browse/AMQ-2290 (I could not find anything else which resembled to our problem)
Therefore we implemented the exact same solution.

@mtaylor
Copy link

mtaylor commented Jul 26, 2017

@AlerantAppNGIN

Can you rebase, so only your commits is showing in the PR. This way I can easily see what changes you have and can review.

… not grow above the maxCacheSize when concurrently calling put)
@JBossJenkins
Copy link

Can one of the admins verify this patch?

2 similar comments
@JBossJenkins
Copy link

Can one of the admins verify this patch?

@JBossJenkins
Copy link

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants