fix for Bug 62432 , clear invalid Entry for org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer #941
+19
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original proposal Bug 62432
The StatementFinalizer keeps a list of statements which he closes
if they're still open when the connection is closed. The list keeps
weak references to the statements, so when the statement is closed
by client code, it can be garbage collected and will not be closed
by the StatementFinalizer.
However, the StatementFinalizer keeps the references to the Statements
indirectly through instances of StatementFinalizer$StatementEntry.
These instances are not cleaned up even when the statements they refer
to have long been closed. Mostly this does not seem to be a problem when
connections are closed quickly.
But we have had long running jobs that created many Statements with
the same connection where the instances of (empty)
StatementFinalizer$StatementEntry finally brought the VM to its knees.
The useless instances of StatementFinalizer$StatementEntry kept
around in the statement list constitute a memory leak in my opinion.
What's new?
A new feature to address the memory leak for StatementFinalizer$statements.
When a new Statement is created, it invokes the function called clearEntry().
The clearEntry function will clean those invalid (null or have been closed)
StatementEntry instances in the list every ten times.