Prossible perf_hooks memory leak detected
See original GitHub issueIt seems nanobus creates a performance entry on event emit and never clear the entry, so after a long time of using, more and more entries of performance will be in memory.
key code here:
var emitTiming = nanotiming(this._name + "('" + eventName + "')")
var listeners = this._listeners[eventName]
if (listeners && listeners.length > 0) {
this._emit(this._listeners[eventName], data)
}
if (this._starListeners.length > 0) {
this._emit(this._starListeners, eventName, data, emitTiming.uuid)
}
emitTiming()
and warning message is:
(node:84217) Warning: Possible perf_hooks memory leak detected. There are 996 entries in the Performance Timeline. Use the clear methods to remove entries that are no longer needed or set performance.maxEntries equal to a higher value (currently the maxEntries is 150).
and my test code is here:
const nanobus = require('nanobus')
const bus = nanobus()
bus.on('foo', () => {})
for (let i=0; i<1000; i++) {
bus.emit('foo', 'bus')
}
I see this message when I use webpack-serve which use nanobus as bus to emit events.
So I guess it’s a bug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Prossible perf_hooks memory leak detected - Bountysource
It seems nanobus creates a performance entry on event emit and never clear the entry, so after a long time of using, more...
Read more >Finding And Fixing Node.js Memory Leaks: A Practical Guide
An introduction to memory debugging, from identifying causes to fixing leaks, using Chrome DevTools, and illustrated by simple examples.
Read more >possible memory leak due to DB close - node.js - Stack Overflow
Problem - you're creating a new connection every time. Solution - connect once and cache the connection. Option 1
Read more >Investigating Memory Leaks with valgrind - Nodejs API 文档
A Node.js process may run out of memory due to excessive consumption of native memory. Native Memory is memory which is not managed...
Read more >Node.js Memory Leak Detection: How to Debug & Avoid Them
Memory leaks often go unnoticed. This is why I suggest using a tool to keep track of historical data of garbage collection cycles...
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 Free
Top 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
Oh yeah, thought of another tweak we could do: we could detect the node version and switch off perf timings if the version is
<10
. Makes it so there’s less compat code to worry about 😄@Jokcy yep, that sounds about right. I was hoping the new timing API would have been backported to
9.x.x
but unfortunately it hasn’t been. On the other hand: 9.x is only being supported until the end of the month so maybe it’s okay to not backport feature detection / support?