Skip to content

Possible memory leak when starting session with lazy @Reference entity #3556

@github-actions

Description

@github-actions

Duplicate of #3513 for milestone 3.0.0


Describe the bug
Metaspace keep increasing without dropping down after repeated query with a new session.
I am not sure if this helps, but I found many $$ReferenceProxy in the heap.

To Reproduce
Steps to reproduce the behavior:

  1. Create an entity with @reference like: @reference(lazy = true, idOnly = true, ignoreMissing = true)

  2. Query the entity repeatedly like:

    FindOptions options = new FindOptions();
    options.sort(Sort.descending("_id"));
    options.limit(1);
    for (int i = 0; i < loop; i++) {
    options.skip(i);
    Datastore ds = getMorphiaDatastore();
    List tmp = new ArrayList<>();
    try(MorphiaSession s = ds.startSession()){
    Query q = s.find(ClazzWithRef, options).filter();
    MorphiaCursor cursor = q.iterator();
    //tmp = cursor.toList();
    cursor.close();
    }
    }

Expected behavior
Metaspace should drop after GC

** Please complete the following information: **

  • Server Version: 8.0.4
  • Driver Version: 5.3.1
  • Morphia Version: 2.5.0

Additional context
Tested with entity with no @reference is fine.
Tested without starting a new session is also fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugforward-portIssues automatically duplicated from other versions via an action

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions