question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory Leak on readStream

See original GitHub issue

Lib version 3.3.1

Here is example

const {
  EventStoreDBClient,
  jsonEvent,
  START,
  FORWARDS
} = require("@eventstore/db-client")

var heapdump = require('heapdump')

const client = new EventStoreDBClient(
  {
    endpoint: "localhost:2113",
  },
  {
    insecure: true,
  }
);

(async () => {
  const streamName = "es_supported_clients"
  const event = jsonEvent({
    type: "grpc-client",
    data: {
      languages: ["typescript", "javascript"],
      runtime: "NodeJS",
    },
  })
  await client.appendToStream(streamName, [event])

  for (let index = 0; index < 10000; index++) {
    const events = client.readStream(streamName, {
      fromRevision: START,
      direction: FORWARDS,
      maxCount: 10,
    })

    // if remove the loop. memory leak even bigger
    for await (const event of events) {
    }
    global.gc()
    console.log(
      // convert to mb
      Math.round((process.memoryUsage().heapUsed / 1024 / 1024) * 100) / 100
    )
  }
  heapdump.writeSnapshot(function (err, filename) {
    console.log('dump written to', filename)
  })
})()

Memory Leak | no loop Memory Leak

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
George-Paynecommented, Aug 18, 2022

Thanks @matchish, good find.

The fix / bit of explanation is here: #310

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory Leak(?) with StreamReader - Stack Overflow
I have a few very large files each of 500MB++ size, containing integer values (in fact it's a bit more complex), I'm reading...
Read more >
Memory leak when a stream in the pipeline gets destroyed ...
dat`); pipeline(readStream, writeStream, (error) => { if (error) { console.log(error); // By uncommenting the next line, the underlying request ...
Read more >
Understanding memory leaks in node.js part 1 - alxolr
In this article we will learn about memory leaks in node.js, we will focus mainly on streams and promises.
Read more >
How to Find, Fix, and Prevent Node.js Memory Leaks
Memory management for any application is essential. This post looks at what memory leaks are and how to avoid them in Node.js applications....
Read more >
How to simply workaround RAM-leaking libraries like ...
Another challenge is to find which code or library caused the leak in your app. What you might get is a huge amount...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found