Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2814

Memory Leak in ForeignKey class

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Major
    • Resolution: Unresolved
    • 3.0.0
    • 3.2.3
    • jdbc
    • None

    Description

      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 ?

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            struberg Mark Struberg
            gregjdf Gregory JEVARDAT

            Dates

              Created:
              Updated:

              Slack

                Issue deployment