Memory Leak on readStream
See original GitHub issueLib 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)
})
})()
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@matchish
v4.0.0
has been released, including this fix.https://www.npmjs.com/package/@eventstore/db-client/v/4.0.0 https://github.com/EventStore/EventStore-Client-NodeJS/releases/tag/v4.0.0
Thanks @matchish, good find.
The fix / bit of explanation is here: #310