Skip to content

Disconnected Consumers Continue To Take Up Space in Heap #369

@brendan620

Description

@brendan620

Environment Information

  • OS: Windows 11
  • Node Version: 22.7.0
  • NPM Version: 10.8.2
  • C++ Toolchain: Visual Studio Code
  • confluent-kafka-javascript version: 1.4.1

Steps to Reproduce

  1. Take a snapshot of the heap usage
  2. Initialize a new Kafka Consumer
  3. Call the Consumer.connect() method
  4. Call the Consumer.disconnect() method
  5. Take a snapshot of the updated heap usage
for(let i = 0; i < 10; i++) {
  const consumer =  kafka.consumer({ kafkaJS: { groupId: `Group-${i}`, fromBeginning: false} });
  await consumer.connect();
  await consumer.disconnect();
}

Running the above snippet and taking heap snapshots between each consumer creation shows that around 1 MB of memory is retained for each disconnected consumer. This can add up over time if an application needs to spin up a large number of consumers.

Comparing the latest heap snapshot to the initial the largest size delta is in the Array constructor which added 7.2MB.

Comparing each snapshot to the previous one shows the same. The Array constructor has the largest size delta and increases at a consistent rate between snapshots.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions