Skip to content

Conn has a memory leak #60

@awake23

Description

@awake23

Environment

node24

Reproduction

none

Describe the bug

While investigating a memory leak related to Conn, I found that ImportClient appears to strongly retain Conn, preventing it from being garbage collected in Node.js.

During testing, explicitly breaking the reference from ImportClient back to Conn allows both Conn and higher-level objects to be released:

Object.values(conn.imports).forEach(v => {
  delete v.rc._client.conn;
});

After this, heap snapshots no longer show Conn or related objects.

This suggests that there is a strong reference cycle involving:

Conn -> imports -> RefCount -> ImportClient -> Conn

I’m not deeply familiar with the intended lifecycle semantics of this library, but this reference chain seems to make it difficult (or impossible) for Conn to be GC’d under normal shutdown, even after closing the transport.

I hope this observation helps narrow down the issue.
Please let me know if a minimal reproduction or heap snapshot would be useful.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions