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.

Prossible perf_hooks memory leak detected

See original GitHub issue

It 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:open
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
yoshuawuytscommented, Jul 10, 2018

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 😄

0reactions
yoshuawuytscommented, Jul 9, 2018

@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?

Read more comments on GitHub >

github_iconTop 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 >

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