Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. #725

Open
chen-xiaoxing opened this issue May 7, 2024 · 2 comments
Labels

Comments

@chen-xiaoxing
Copy link

chen-xiaoxing commented May 7, 2024

Description

When I subscribe, I get the data. After the data is processed, I do unsubscription in the method. This subscription is issued when the scroll bar scrolls on the page, but it shows a memory leak.

  • Library Version: angular@8+roslib@1.1.0+node@14.21.3+ts@3.5.3
  • ROS Version:1.1.0
  • Platform / OS: windows11+vscode

Steps To Reproduce

let arr= [];
this.mapRosService.observeLandmark.subscribe(res => {
      arr= [];
      (res.markers).forEach(res1 => {
        let str = res1.pose.position;
        let obj = {
          x: str.x,
          y: str.y,
        }
        arr.push(obj);
      })
      this.mapRosService.observeLandmark.unsubscribe();
    })

Expected Behavior
Memory will not leak

Actual Behavior
Memory leak

@MatthijsBurgh
Copy link
Contributor

This is incomplete as we need the message your are receiving.

Plus when it is a bug in EventEmitter, we can't fix it. So please describe what roslib is doing wrong. Please note your are using a significantly old library and node version. So whatever your issue might be, I suggesst you first test the latest 1.X version. with node 18, as node 16 is aleady EOL.

@chen-xiaoxing
Copy link
Author

Yes, my node and roslib versions are a bit old. The company has no plans to upgrade them at the moment. Let’s get back to this question.If you subscribe to the same roslib more than 11 times, an error will be reported.
I encapsulated the subscription to roslib in a method. This method is called when the mouse scrolls. When I continue to scroll the mouse (subscribe more than 11 times), a memory leak appears.The browser console error message points to the location where roslib is subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants