[
https://issues.apache.org/jira/browse/OPENJPA-2814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gregory JEVARDAT reopened OPENJPA-2814:
---------------------------------------
[~struberg] Hello, I could finally test it and there is in some specific cases
that I did not yet identified precisely a stack overflow error.
Here is the stack trace I have using latest 3.2.0
I have impression that equals in ForeignKey might be using to many fields. Why
not relying on the existing equalsForeignKey method btw ?
{code:java}
Caused by: java.lang.StackOverflowError
at org.apache.openjpa.jdbc.schema.Constraint.equals(Constraint.java:261)
at org.apache.openjpa.jdbc.schema.ForeignKey.equals(ForeignKey.java:927)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2000)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
at java.base/java.util.HashMap$TreeNode.find(HashMap.java:2010)
...
{code}
> Memory Leak in ForeignKey class
> -------------------------------
>
> Key: OPENJPA-2814
> URL: https://issues.apache.org/jira/browse/OPENJPA-2814
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 3.0.0
> Reporter: Gregory JEVARDAT
> Assignee: Mark Struberg
> Priority: Major
> Fix For: 3.2.0
>
>
> I analyzed and solved a memory leak in the ForeignKey class.
>
> Context is that I run a batch application running as a service and reading
> billions of entities.
> I realised that ForeignKey classes were accumulating in the heap after each
> query reading these entities and were never garbaged leading after few
> hundreds of millions of read and hours of processing to full heap.
> After profiling and debugging the leak is coming from the
> ForeignKey.join(Column local,Column toPOK) method, more precisely in the line
> 574 were
> local.addConstraint(this) is performed.
> Here the ForeignKeys are added to a Set in the Column class.
> Issue is that the ForeignKey has no equals and hashcode implemented resulting
> in what it seems to me logically equivalent ForeignKeys added and
> accumulating indefinitely in the map of Columns. Indeed, for whatever reason
> a new ForeignKey class is created each time (which also sounds weird) at
> RelationFieldStrategy.createTranslatingForeignKey method
> Solution: after implementing equals and hashcode in ForeignKey and Constraint
> class, the application works smoothly and the memory leak is gone. Maybe it
> should be done for DBIdentifier also ?
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)